-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsnake_water_gun
More file actions
63 lines (48 loc) · 1.71 KB
/
snake_water_gun
File metadata and controls
63 lines (48 loc) · 1.71 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
58
59
60
61
62
63
# SNAKE WATER GUN GAME IN PYTHON
// URL: https://ide.geeksforgeeks.org/mn7zvkOBlX
# let's begin
#code
import random
print("\t** SNAKE WATER GUN GAME IN PYTHON **")
wins = 0
lose = 0
draws = 0
chance = 0
#you can also take the input in form of numbers, i will go with charachter
promt = "s for snake \nw for water \ng for gun \nq to quit \nEnter your choice:"
while True:
user_choice = input(promt).lower()
while user_choice not in ['s','w','g','q']:
print("\nplease enter a valid choice")
user_choice = input(promt).lower()
if user_choice == 'q':
break
else:
comp_choice = random.choice(['s','w','g'])
chance += 1
if comp_choice == 's':
move = "snake"
elif comp_choice == 'w':
move = "water"
else:
move = "gun"
print("\nSystem choice is {}".format(move))
if comp_choice == user_choice:
print("Draws!..")
draws += 1
elif(user_choice == 's' and comp_choice =='w') or (user_choice == 'w' and comp_choice=='g') or (user_choice == 'g' and comp_choice == 's'):
print("You Win!..")
wins += 1
else:
print("You lose!..")
lose += 1
print("\n\nYou played total " + str(chance) +" number of times in which you have total:- ")
print("no. of wins: "+str(wins)+"\nno. of lose: "+str(lose)+"\nDraws: "+str(draws))
# to make more interesting add this.
if wins > lose:
print("\nCongrats Overall game is yours")
elif lose > wins:
print("\nOverall game was on computer side")
print("Better luck next time.")
else:
print("\nOverall game Draws")