11.Snake Water Gun Game.py

 # Snake Water Gun



#Snake,Water and Gun is a variation of the children's game "Rock-Paper-Scissors"
# where players use hand gestures to represent a snake, water, or a gun.
# The gun beats the snake, the water beats the gun, and the snake beats the water.


# Write a python program to create a Snake Water Gun game in Python using if-else statements.
# Don't create any fancy GUI. Use proper functions to check for win.


# S W G
# Computer = 0 1 2
# Player = S 0 D W L
# W 1 L D W
# G 2 W L D


import random

def check (comp,user):
if comp == user:
return 0
if comp == 2 and user == 0:
return -1
if comp == 1 and user == 2:
return -1
if comp == 0 and user == 1:
return -1
else:
return 1

comp =random.randint(0,2)
# print(comp)
user =int(input("0 for Snake, 1 for Water, 2 for Gun: \n"))

print("You:",user)
print("Computer:",comp)

score = check(comp,user)
if score == 0:
print("It is a draw")
elif score == -1:
print("You Lose")
else:
print("You Won")

Comments

Popular posts from this blog

3.FaulyCalculator.py

15.PyStopWatch.py