From ca5f1b4e499e2e0a3d16e228a65b27350feaca1f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jul 2025 16:04:21 +0200 Subject: initial commit --- rock_paper_scissors.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 rock_paper_scissors.py (limited to 'rock_paper_scissors.py') diff --git a/rock_paper_scissors.py b/rock_paper_scissors.py new file mode 100755 index 0000000..cbabb97 --- /dev/null +++ b/rock_paper_scissors.py @@ -0,0 +1,42 @@ +import random + +user_wins = 0 +computer_wins = 0 + +options = ["rock", "paper", "scissors"] + +while True: + user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower() + if user_input == "q": + break + + if user_input not in options: + continue + + random_number = random.randint(0, 2) + # rock: 0, paper: 1, scissors: 2 + computer_pick = options[random_number] + print("Computer picked", computer_pick + ".") + + if user_input == "rock" and computer_pick == "scissors": + print("You won!") + user_wins = user_wins + 1 + + elif user_input == "scissors" and computer_pick == "paper": + print("You won!") + user_wins = user_wins + 1 + + elif user_input == "paper" and computer_pick == "rock": + print("You won!") + user_wins = user_wins + 1 + + elif user_input == computer_pick: + print("DRAW") + + else: + print("You lost!") + computer_wins = computer_wins + 1 + +print("You won", user_wins, "times.") +print("The computer won", computer_wins, "times.") +print("Goodbye!") \ No newline at end of file -- cgit v1.2.3