Skip to content

Commit 139c72c

Browse files
authored
Add files via upload
1 parent 4f78a6a commit 139c72c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Snake-Water-Game/Snake-Water Game.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from ctypes.wintypes import PINT
2+
from math import gamma
3+
from pickle import TRUE
4+
import random
5+
from tkinter.tix import Tree
6+
7+
8+
def game(comp,mine):
9+
if(comp==mine):
10+
return None
11+
if(comp=='snake' and mine=='gun'):
12+
return True
13+
elif(comp=='water' and mine=='snake'):
14+
return True
15+
elif(comp=='gun' and mine=='water'):
16+
return True
17+
else:
18+
return False
19+
20+
# Here is the main code started... #
21+
22+
choice=('snake','water','gun')
23+
# choice is tuple and it will not change in future
24+
comp=random.randint(0,2)
25+
comp=choice[comp]
26+
# choosing one comp if user pick the value like
27+
# 0-snake
28+
# 1-water
29+
# 2-gun
30+
# 3-invalid input
31+
mine=input('Your input:')
32+
if(mine=='snake' or mine=='gun' or mine=='water'):
33+
WinTheGame=game(comp,mine)
34+
else:
35+
WinTheGame=-1
36+
print(f"You choose {mine} and the computer choose {comp}")
37+
if WinTheGame==-1:
38+
print('Invalid input.')
39+
elif WinTheGame is None:
40+
print('Match is drawn.')
41+
elif WinTheGame:
42+
print("You Won.")
43+
else:
44+
print("You Lose.")

0 commit comments

Comments
 (0)