-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest3.py
More file actions
57 lines (56 loc) · 1.51 KB
/
Test3.py
File metadata and controls
57 lines (56 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# CodeWithHarry
# Exercise 6
# Snake Water Gun Game
import random
i = 0
compwin = 0
youwin = 0
tie = 0
while(i < 10):
print("SNAKE WATER GUN GAME")
list = ["Snake", "Water", "Gun"]
compchoice = random.choice(list)
print("Snake->s")
print("Water->w")
print("Gun->g")
ch = input("Enter your choice(s/w/g): ")
print(f"Computer's choice {compchoice}")
print("\n")
if(compchoice == "Snake" and ch == "s"):
tie += 1
elif(compchoice == "Snake" and ch == "w"):
compwin += 1
elif(compchoice == "Snake" and ch == "g"):
youwin += 1
elif(compchoice == "Water" and ch == "s"):
youwin += 1
elif(compchoice == "Water" and ch == "w"):
tie += 1
elif(compchoice == "Water" and ch == "g"):
compwin += 1
elif(compchoice == "Gun" and ch == "s"):
compwin += 1
elif(compchoice == "Gun" and ch == "w"):
youwin += 1
elif(compchoice == "Gun" and ch == "g"):
tie += 1
i += 1
if(compwin > youwin):
print("Games Won")
print(f"Computer: {compwin}")
print(f"You: {youwin}")
print(f"Ties: {tie}")
print("Computer wins")
elif(youwin > compwin):
print("Games Won")
print(f"Computer: {compwin}")
print(f"You: {youwin}")
print(f"Ties: {tie}")
print("You win")
elif(youwin == compwin):
print("Games Won")
print(f"Computer: {compwin}")
print(f"You: {youwin}")
print(f"Ties: {tie}")
print("Nobody wins")
print("\n")