From fccb2ba4c221e6e6f9f54784dd789b652fe09a10 Mon Sep 17 00:00:00 2001 From: Madhuj275 Date: Mon, 28 Oct 2024 20:10:28 +0530 Subject: [PATCH 1/2] Create Rock Paper Scissor.py --- Python/Rock Paper Scissor.py | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Python/Rock Paper Scissor.py diff --git a/Python/Rock Paper Scissor.py b/Python/Rock Paper Scissor.py new file mode 100644 index 00000000..932ad5ef --- /dev/null +++ b/Python/Rock Paper Scissor.py @@ -0,0 +1,54 @@ +import random +choices = ['rock', 'paper', 'scissors'] +comp_choice = random.choice(choices) +player_wins = 0 +comp_wins = 0 +tie = 0 + +print("Welcome to [Rock Paper Scissors]") + +while True: + comp_choice = random.choice(choices) + answer = input("----Type [play] to play, [exit] to exit------\n") + + if answer == "play": + while True: + choice = input("Enter you choice [rock/paper/scissors] :\n") + choice = choice.lower() + if choice == 'rock' and comp_choice == 'paper': + print("- Computer chose paper\n[!] Computer Wins!") + comp_wins += 1 + break + elif choice == 'rock' and comp_choice == 'scissors': + print("- Computer chose scissors\n[!] Yon Win!") + player_wins += 1 + break + elif choice == 'paper' and comp_choice == 'rock': + print("- Computer chose rock\n[!] You Win!") + player_wins += 1 + break + elif choice == 'paper' and comp_choice == 'scissors': + print("- Computer chose scissors\n[!] Computer Wins!") + comp_wins += 1 + break + elif choice == 'scissors' and comp_choice == 'rock': + print("- Computer chose rock\n[!] Computer Wins!") + comp_wins += 1 + break + elif choice == 'scissors' and comp_choice == 'paper': + print("- Computer chose paper\n[!] You Win!") + player_wins += 1 + break + elif choice == comp_choice: + print(f"- Computer chose {comp_choice}\n[!] It's a Tie!") + tie += 1 + break + else: print(" Not a valid choice, Try again") + + elif answer == "exit": + break + else: + print("[~] Not a valid answer, Try again") + +print(f"- You won {player_wins} times\n- Computer wins {comp_wins} times\n- It was a tie {tie} times") +print("-------------- Thanks for playing!-------------------") From 0764e9d559b620b9e3e751b0b9c985099bde6a6b Mon Sep 17 00:00:00 2001 From: Madhuj275 Date: Mon, 28 Oct 2024 20:20:58 +0530 Subject: [PATCH 2/2] Update Rock Paper Scissor.py --- Python/Rock Paper Scissor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Python/Rock Paper Scissor.py b/Python/Rock Paper Scissor.py index 932ad5ef..48c227b9 100644 --- a/Python/Rock Paper Scissor.py +++ b/Python/Rock Paper Scissor.py @@ -1,3 +1,7 @@ +# Username:Madhuj275 +#Aim : Implement Rock Paper Scissor Game using Algorithm +# Date: 28/10/24 + import random choices = ['rock', 'paper', 'scissors'] comp_choice = random.choice(choices)