Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a978f35

Browse files
committedDec 13, 2024
Snake water gun game
1 parent 41a262c commit a978f35

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
 

‎ex-5 (snake water gun game).py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# S W G
2+
# computer = 0 1 2
3+
# player = S 0 D W L
4+
# W 1 L D W
5+
# G 2 W L D
6+
import random
7+
def check(comp,user):
8+
if comp==user:
9+
return 0
10+
if(comp==0 and user==1):
11+
return -1
12+
if(comp==1 and user==2):
13+
return -1
14+
if(comp==2 and user==0):
15+
return -1
16+
return 1
17+
comp=random.randint(0,2)
18+
user=int(input("enter 0 snake 1 water 2 gun:"))
19+
# print(comp("Computer enters the value(0-2):"))
20+
score=check(comp,user)
21+
print("you",user)
22+
print("computer",comp)
23+
if (score==0):
24+
print("its draw")
25+
elif(score==-1):
26+
print("loss")
27+
else:
28+
print("you won ")
29+

0 commit comments

Comments
 (0)
Please sign in to comment.