From e4efc624e15de34c62f5e2df81653d1716d9f245 Mon Sep 17 00:00:00 2001 From: Jawad Sher Date: Wed, 29 May 2024 16:08:53 +0500 Subject: [PATCH] Adding fourth Project --- Project 4 - Rock Paper Scissor/README.md | 0 Project 4 - Rock Paper Scissor/main.py | 75 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 Project 4 - Rock Paper Scissor/README.md create mode 100644 Project 4 - Rock Paper Scissor/main.py diff --git a/Project 4 - Rock Paper Scissor/README.md b/Project 4 - Rock Paper Scissor/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Project 4 - Rock Paper Scissor/main.py b/Project 4 - Rock Paper Scissor/main.py new file mode 100644 index 0000000..d72568b --- /dev/null +++ b/Project 4 - Rock Paper Scissor/main.py @@ -0,0 +1,75 @@ +import random + +print("Welcome to ---> Rock Paper Scissor Game <--- ") +print("---------> H U M A N vs C O M P U T E R <---------") +print() +print("***** WINING GAME RULES *****") +print("ROCK vs PAPER --> PAPER WINS\n" + +"ROCK vs SCISSOR--> ROCK WINS\n" + +"PAPER vs SCISSOR --> SCISSOR WINS\n") + +rounds = int(input("Enter Number of Rounds : ")) +userChoice = "" +computerChoice = "" +while(rounds): + rounds = rounds -1 + + choices = ['ROCK', 'PAPER', 'SCISSOR'] + for index, val in enumerate(choices): + print(index+1,"-", val) + + print() + userInput = int(input("Enter your Choice : ")) -1 + match userInput: + case userInput : + userChoice = choices[userInput] + print("Your Choice is : ", userChoice) + + print() + computerInput = random.randint(0, 2) + match computerInput: + case computerInput : + computerChoice = choices[computerInput] + print("Computer Choice is : ", computerChoice) + + print() + if(userChoice == "ROCK" and computerChoice == "PAPER"): + print(f'Computer Choice : {computerChoice} - COMPUTER WINS') + print("Try! Next Time") + + elif(userChoice == "PAPER" and computerChoice == "ROCK"): + print(f'Your Choice : {userChoice} - YOU WIN') + print("Congratulations") + + elif(userChoice == "ROCK" and computerChoice == "SCISSOR"): + print(f'Your Choice : {userChoice} - YOU WIN') + print("Congratulations") + + elif(userChoice == "SCISSOR" and computerChoice == "ROCK"): + print(f'Computer Choice : {computerChoice} - COMPUTER WINS') + print("Try! Next Time") + + elif(userChoice == "SCISSOR" and computerChoice == "PAPER"): + print(f'Your Choice : {userChoice} - You WIN') + print("Congratulations") + + elif(userChoice == "PAPER" and computerChoice == "SCISSOR"): + print(f'Computer Choice : {computerChoice} - COMPUTER WINS') + print("Try! Next Time") + + else: + print("ooooooohh - GAME DRAW") + + again = input("You want to play again yes/no: ") + match again: + case 'yes': + rounds += 1 + case 'no' : + rounds += 0 + print("ROUNDS OVER") + exit() + + + + +