|
| 1 | +import random |
| 2 | + |
| 3 | +print("Welcome to ---> Rock Paper Scissor Game <--- ") |
| 4 | +print("---------> H U M A N vs C O M P U T E R <---------") |
| 5 | +print() |
| 6 | +print("***** WINING GAME RULES *****") |
| 7 | +print("ROCK vs PAPER --> PAPER WINS\n" |
| 8 | + +"ROCK vs SCISSOR--> ROCK WINS\n" |
| 9 | + +"PAPER vs SCISSOR --> SCISSOR WINS\n") |
| 10 | + |
| 11 | +rounds = int(input("Enter Number of Rounds : ")) |
| 12 | +userChoice = "" |
| 13 | +computerChoice = "" |
| 14 | +while(rounds): |
| 15 | + rounds = rounds -1 |
| 16 | + |
| 17 | + choices = ['ROCK', 'PAPER', 'SCISSOR'] |
| 18 | + for index, val in enumerate(choices): |
| 19 | + print(index+1,"-", val) |
| 20 | + |
| 21 | + print() |
| 22 | + userInput = int(input("Enter your Choice : ")) -1 |
| 23 | + match userInput: |
| 24 | + case userInput : |
| 25 | + userChoice = choices[userInput] |
| 26 | + print("Your Choice is : ", userChoice) |
| 27 | + |
| 28 | + print() |
| 29 | + computerInput = random.randint(0, 2) |
| 30 | + match computerInput: |
| 31 | + case computerInput : |
| 32 | + computerChoice = choices[computerInput] |
| 33 | + print("Computer Choice is : ", computerChoice) |
| 34 | + |
| 35 | + print() |
| 36 | + if(userChoice == "ROCK" and computerChoice == "PAPER"): |
| 37 | + print(f'Computer Choice : {computerChoice} - COMPUTER WINS') |
| 38 | + print("Try! Next Time") |
| 39 | + |
| 40 | + elif(userChoice == "PAPER" and computerChoice == "ROCK"): |
| 41 | + print(f'Your Choice : {userChoice} - YOU WIN') |
| 42 | + print("Congratulations") |
| 43 | + |
| 44 | + elif(userChoice == "ROCK" and computerChoice == "SCISSOR"): |
| 45 | + print(f'Your Choice : {userChoice} - YOU WIN') |
| 46 | + print("Congratulations") |
| 47 | + |
| 48 | + elif(userChoice == "SCISSOR" and computerChoice == "ROCK"): |
| 49 | + print(f'Computer Choice : {computerChoice} - COMPUTER WINS') |
| 50 | + print("Try! Next Time") |
| 51 | + |
| 52 | + elif(userChoice == "SCISSOR" and computerChoice == "PAPER"): |
| 53 | + print(f'Your Choice : {userChoice} - You WIN') |
| 54 | + print("Congratulations") |
| 55 | + |
| 56 | + elif(userChoice == "PAPER" and computerChoice == "SCISSOR"): |
| 57 | + print(f'Computer Choice : {computerChoice} - COMPUTER WINS') |
| 58 | + print("Try! Next Time") |
| 59 | + |
| 60 | + else: |
| 61 | + print("ooooooohh - GAME DRAW") |
| 62 | + |
| 63 | + again = input("You want to play again yes/no: ") |
| 64 | + match again: |
| 65 | + case 'yes': |
| 66 | + rounds += 1 |
| 67 | + case 'no' : |
| 68 | + rounds += 0 |
| 69 | + print("ROUNDS OVER") |
| 70 | + exit() |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
0 commit comments