From 51d0f303777c0ba5f7e445c95e0d90c8472c7926 Mon Sep 17 00:00:00 2001 From: Lalaine Joy Bejarin <86933716+daeserenity@users.noreply.github.com> Date: Wed, 19 Jun 2024 07:19:10 +0000 Subject: [PATCH] Make rock paper scissor game --- .vscode/settings.json | 6 ++++++ app.py | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..764a7f7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cSpell.words": [ + "devcontainers", + "pylance" + ] +} \ No newline at end of file diff --git a/app.py b/app.py index e69de29..ec98675 100644 --- a/app.py +++ b/app.py @@ -0,0 +1,20 @@ +import random + +def play_game(): + choices = ['rock', 'paper', 'scissors'] + computer_choice = random.choice(choices) + user_choice = input("Enter your choice (rock, paper, or scissors): ").lower + + print(f"Computer chose: {computer_choice}") + print(f"You chose: {user_choice}") + + if user_choice == computer_choice: + print("It's a tie!") + elif (user_choice == 'rock' and computer_choice == 'scissors') or \ + (user_choice == 'paper' and computer_choice == 'rock') or \ + (user_choice == 'scissors' and computer_choice == 'paper'): + print("You win!") + else: + print("Computer wins!") + +play_game()