|
| 1 | +import random |
| 2 | +list=["s","p","sc"] |
| 3 | +choice = random.choice(list) |
| 4 | + |
| 5 | +print("s for stone\n") |
| 6 | +print("p for paper\n") |
| 7 | +print("sc for scicors\n") |
| 8 | +print("choose any one from this\n") |
| 9 | + |
| 10 | +user_point = 0 |
| 11 | +computer_point = 0 |
| 12 | + |
| 13 | +number_of_attempts = 1 |
| 14 | +while (number_of_attempts < 11) : |
| 15 | + choice = random.choice(list) |
| 16 | + a=str(input()) |
| 17 | + if (a == "s" and choice == "p") : |
| 18 | + print("The computer used paper, so you lost") |
| 19 | + |
| 20 | + elif (a == "s" and choice == "sc") : |
| 21 | + print("The computer used scicors, so you win") |
| 22 | + |
| 23 | + elif (a == "p" and choice == "s") : |
| 24 | + print("The computer used stone, so you win") |
| 25 | + |
| 26 | + elif (a =="p" and choice == "sc") : |
| 27 | + print("The computer used scicors, so you lost") |
| 28 | + |
| 29 | + elif (a == "sc" and choice == "s") : |
| 30 | + print("The computer used stone, so you lost") |
| 31 | + |
| 32 | + elif (a == "sc" and choice == "p") : |
| 33 | + print("The computer used paper, so you win") |
| 34 | + |
| 35 | + elif(a== choice): |
| 36 | + print("You and computer used same") |
| 37 | + |
| 38 | + else : |
| 39 | + print("Invalid statement please try again") |
| 40 | + exit |
| 41 | + |
| 42 | + number_of_attempts = number_of_attempts + 1 |
| 43 | + |
| 44 | + print("Number of attempts remaining",11-number_of_attempts) |
| 45 | + |
| 46 | + if (a == "s" and choice == "sc" or a == "p" and choice == "s" or a == "sc" and choice == "p") : |
| 47 | + user_point = user_point + 1 |
| 48 | + |
| 49 | + |
| 50 | + elif(a == "s" and choice == "p" or a =="p" and choice == "sc" or a == "sc" and choice == "s") : |
| 51 | + computer_point = computer_point + 1 |
| 52 | + |
| 53 | + else : |
| 54 | + user_point = user_point |
| 55 | + computer_point = computer_point |
| 56 | + print(f"Your score is {user_point} and computer score is {computer_point}") |
| 57 | + |
| 58 | +if (user_point > computer_point) : |
| 59 | + print("You won the match") |
| 60 | +else : |
| 61 | + print("You lost the match") |
| 62 | + |
0 commit comments