From 90b81309335971eeee0e559f338531520a3ad3fb Mon Sep 17 00:00:00 2001 From: Ritam Acharya Date: Fri, 14 Jun 2024 01:30:04 +0530 Subject: [PATCH] add code for rock paper scissor game --- app.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/app.py b/app.py index e69de29..3051d00 100644 --- a/app.py +++ b/app.py @@ -0,0 +1,44 @@ +import random; +options = ["rock" , "paper", "scissors"]; + +score = 0; +rounds = 0; + +while True: + computer_choice = random.choice(options); + player_choice = input( "rock , paper or scissors ? "); + + if player_choice.lower() == "rock" : + if computer_choice == "rock" : + print("Match tie ..."); + rounds += 1; + elif computer_choice == "paper": + rounds += 1; + elif computer_choice == "scissors": + score += 1; + rounds += 1; + elif player_choice.lower() == "paper" : + if computer_choice == "paper" : + print("Match tie ..."); + rounds += 1; + elif computer_choice == "scissors": + rounds += 1; + elif computer_choice == "rock": + score += 1; + rounds += 1; + elif player_choice.lower() == "scissors" : + if computer_choice == "scissors" : + print("Match tie ..."); + rounds += 1; + elif computer_choice == "rock": + rounds += 1; + elif computer_choice == "paper": + score += 1; + rounds += 1; + else : + print("Invalid input ! Please select the correct one..."); + + play_again = input ("Do you want to play again ? (y/N) "); + if play_again.lower() == "n": + print(f"your total score is {score} and rounds played {rounds} "); + break; \ No newline at end of file