Skip to content

Commit 79943a3

Browse files
Merge pull request #1823 from Parmesh119/master
Added the new game script in python by Parmesh Bhatt
2 parents dc72c50 + f5b6d24 commit 79943a3

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

Snake-Water-Game/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Snake-Water-Game
2+
3+
4+
![Screenshot (83)](https://user-images.githubusercontent.com/101285245/201472214-de346df8-bd26-4af2-bfe5-d1c7516ce29f.png)

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)