|
| 1 | +import random |
| 2 | + |
| 3 | +print("ROCK\nPAPER\nSCISSORS") |
| 4 | +print("-----------------------------\n") |
| 5 | +print("r for rock\np for paper\ns for scissors\n--------\n") |
| 6 | + |
| 7 | +lst=['r','p','s'] |
| 8 | + |
| 9 | +chance_taken=0 |
| 10 | +comp_point=0 |
| 11 | +player_point=0 |
| 12 | +remain_chance=10 |
| 13 | + |
| 14 | +while(remain_chance>chance_taken): |
| 15 | + ip=input("enter your selection: ") |
| 16 | + c=random.choice(lst) |
| 17 | + |
| 18 | + if c==ip: |
| 19 | + print("Both tie so 0 point to both") |
| 20 | + |
| 21 | + |
| 22 | + elif c=='r' and ip=='p': |
| 23 | + print(f"You entered {ip} and computer entered {c}") |
| 24 | + print("You wins 1 point") |
| 25 | + player_point=player_point+1 |
| 26 | + print(f"Your score:{player_point}\t computer score:{comp_point}") |
| 27 | + |
| 28 | + elif c=='r' and ip=='s': |
| 29 | + print(f"You entered {ip} and computer entered {c}") |
| 30 | + print("Computer wins 1 point") |
| 31 | + comp_point=comp_point+1 |
| 32 | + print(f"Your score:{player_point}\t computer score:{comp_point}") |
| 33 | + |
| 34 | + elif c=='p' and ip=='r': |
| 35 | + print(f"You entered {ip} and computer entered {c}") |
| 36 | + print("Computer wins 1 point") |
| 37 | + comp_point=comp_point+1 |
| 38 | + print(f"Your score:{player_point}\t computer score:{comp_point}") |
| 39 | + |
| 40 | + elif c=='p' and ip=='s': |
| 41 | + print(f"You entered {ip} and computer entered {c}") |
| 42 | + print("You wins 1 point") |
| 43 | + player_point=player_point+1 |
| 44 | + print(f"Your score:{player_point}\t computer score:{comp_point}") |
| 45 | + |
| 46 | + elif c == 's' and ip == 'r': |
| 47 | + print(f"You entered {ip} and computer entered {c}") |
| 48 | + print("You wins 1 point") |
| 49 | + player_point = player_point + 1 |
| 50 | + print(f"Your score:{player_point}\t computer score:{comp_point}") |
| 51 | + |
| 52 | + elif c=='s' and ip=='p': |
| 53 | + print(f"You entered {ip} and computer entered {c}") |
| 54 | + print("Computer wins 1 point") |
| 55 | + comp_point=comp_point+1 |
| 56 | + print(f"Your score:{player_point}\t computer score:{comp_point}") |
| 57 | + |
| 58 | + else: |
| 59 | + print("enter valid choice ") |
| 60 | + continue |
| 61 | + |
| 62 | + chance_taken=chance_taken+1 |
| 63 | + print(f"you have consumed:{chance_taken} chance \t remaing chances :{remain_chance-chance_taken}") |
| 64 | + print("-----------------------------\n") |
| 65 | + |
| 66 | + |
| 67 | +if(comp_point==player_point): |
| 68 | + print("Gameover\nThis is a tie") |
| 69 | + |
| 70 | +elif comp_point>player_point: |
| 71 | + print("Game over\nSorry..you lose..play again") |
| 72 | + |
| 73 | +elif comp_point<player_point: |
| 74 | + print("Game over\nHurray...You win") |
| 75 | + |
| 76 | +print(f"Your score :{player_point}\t Computer score :{comp_point}") |
0 commit comments