|
| 1 | +import random |
| 2 | +def round(n): |
| 3 | + pgm = 0 |
| 4 | + usr = 0 |
| 5 | + for i in range(n): |
| 6 | + ip=int(input(str(i+1)+". Enter a number(1-3) \n1. Stone\t2. Paper\t3. Scissors : ")) |
| 7 | + cp=random.randint(1,3) |
| 8 | + print(a[cp-1]) |
| 9 | + if ip==cp: |
| 10 | + print("Draw") |
| 11 | + elif ip+1==cp or (ip==3 and cp==1): |
| 12 | + pgm += 1 |
| 13 | + print("Computer Scored a point") |
| 14 | + |
| 15 | + elif (ip - 1 == cp or (cp == 3 and ip == 1)): |
| 16 | + usr += 1 |
| 17 | + print("You Scored a point") |
| 18 | + else: |
| 19 | + print("You entered a wrong Number") |
| 20 | + i=i-1 |
| 21 | + print("Your score :"+str(usr)+"\nComputer Score :"+str(pgm)) |
| 22 | + print("-----Game Over-----") |
| 23 | + |
| 24 | +a=["stone","paper","scissors"] |
| 25 | +n=int(input("how many turns you want in a round?")) |
| 26 | +while(True): |
| 27 | + round(n) |
| 28 | + s=input("Do you want to play again?(Y/N) : ") |
| 29 | + if s=='N' or s=='n': |
| 30 | + break |
| 31 | +print("-----Thank you-----") |
0 commit comments