Skip to content

Commit ab75568

Browse files
authored
Merge pull request #64 from Yuktikashyap/main
Snake, Water and Gun Pyhton Project
2 parents 901f0d8 + ef29908 commit ab75568

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Snake_Water_Gun_Game.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
import random
3+
4+
print("Player no.1- choose snake(1) , water(2) or gun(3)")
5+
6+
comp = random.randint(1,3)
7+
8+
you = input("Player no.2- choose snake(s) , water(w) or gun(g)")
9+
if comp == 1:
10+
comp = "s"
11+
elif comp == 2:
12+
comp = "w"
13+
elif comp == 3:
14+
comp = "g"
15+
def gamewin(comp,you):
16+
17+
# by chance if both you and comp choose same thing
18+
if comp == you:
19+
return None
20+
# check for all posibilities when comp choose snake(s)
21+
if comp=="s":
22+
if you == "w":
23+
return False
24+
elif you == "g":
25+
return True
26+
# if computer has snake and you choose water then you will loose
27+
# so it will return false and if you have gun then return true
28+
# this means you win
29+
30+
# check for all posibilities when comp choose water(w)
31+
elif comp=="w":
32+
if you == "g":
33+
return False
34+
elif you == "s":
35+
return True
36+
37+
# check for all posibilities when comp choose gun(g)
38+
elif comp=="g":
39+
if you == "s":
40+
return False
41+
elif you == "w":
42+
return True
43+
44+
s = gamewin(comp,you)
45+
46+
print("the vlaue choosen by computer",comp)
47+
print("the vlaue choosen by you",you)
48+
# this will print what computer and you have choosen
49+
# ( in case you wnated to know)
50+
if s == None:
51+
print(" the game has tie!!!!")
52+
elif s == True:
53+
print("You win the game!!")
54+
else :
55+
print("You loose the game !!")

0 commit comments

Comments
 (0)