|
| 1 | +# We have 3 choice for selecting snake, water, function |
| 2 | +# we have selected anything from 3 choices |
| 3 | +# computer choose randomly among three choices |
| 4 | + |
| 5 | +# if I choose snake and computer choose water then snake win |
| 6 | +# if I choose snake and computer choose gun then gun win |
| 7 | +# if I choose snake and computer choose snake then match draw |
| 8 | + |
| 9 | +# if I choose gun and computer choose water then water win |
| 10 | +# if I choose gun and computer choose water then gun win |
| 11 | +# if I choose gun and computer choose water then gun match tie |
| 12 | + |
| 13 | +# if I choose water and computer choose gun then water won |
| 14 | +# if I choose water and computer choose snake then snake won |
| 15 | +# if I choose water and computer choose water then draw |
| 16 | + |
| 17 | +import random |
| 18 | + |
| 19 | +score = 0 |
| 20 | +i = 1 |
| 21 | + |
| 22 | +while i <= 5: |
| 23 | + |
| 24 | + computer_guesses = ['snake', 'water', 'gun'] |
| 25 | + print(f"{i}. Computer has choose value....") |
| 26 | + compChoice = random.choice(computer_guesses) |
| 27 | + |
| 28 | + print("Choose any one from snake, water, gun ") |
| 29 | + myChoice = input() |
| 30 | + |
| 31 | + if myChoice == "snake" or myChoice == "water" or myChoice == "gun": |
| 32 | + if myChoice == 'snake' and compChoice == 'water': |
| 33 | + print("You win!!") |
| 34 | + score += 1 |
| 35 | + elif myChoice == 'snake' and compChoice == 'gun': |
| 36 | + print("You lost!!") |
| 37 | + elif myChoice == 'water' and compChoice == 'gun': |
| 38 | + print("You win!!") |
| 39 | + score += 1 |
| 40 | + elif myChoice == 'water' and compChoice == 'snake': |
| 41 | + print("You lost!!") |
| 42 | + elif myChoice == 'gun' and compChoice == 'snake': |
| 43 | + print("You win!!") |
| 44 | + score += 1 |
| 45 | + elif myChoice == 'gun' and compChoice == 'water': |
| 46 | + print("You lost!!") |
| 47 | + else: |
| 48 | + print("Match draw!!") |
| 49 | + i += 1 |
| 50 | + else: |
| 51 | + print("Enter valid input...") |
| 52 | +print("\nYour Total score: ", score) |
0 commit comments