snake water gun game in python
# Snake water gun game in python
'''
Snake vs. Water: Snake drinks the water hence wins.
Water vs. Gun: The gun will drown in water, hence a point for water
Gun vs. Snake: Gun will kill the snake and win.
In situations where both players choose the same object, the result will be a draw.
'''
import random
user = 0
computer = 0
turns = 0
while (turns<10):
a = ['Snake','Water','Gun']
pc = random.choice(a)
print(pc)
turns +=1
dic = {1:'Snake',2:'Water',3:'Gun'}
b = int(input('1.Snake,2.Water,3.Gun'))
if b in dic:
print(dic[b])
if pc == 'Snake':
if dic[b] == 'Snake':
print('its tie')
elif dic[b] == 'Water':
print('PC wins')
computer +=1
elif dic[b] == 'Gun':
print('user wins')
user+=1
elif pc == 'Water':
if dic[b] == 'Snake':
print('user wins')
user+=1
elif dic[b] == 'Water':
print('its tie')
elif dic[b] == 'Gun':
print('computer wins')
computer +=1
elif pc == 'Gun':
if dic[b] == 'Snake':
print('PC wins')
computer+=1
elif dic[b] == 'Water':
print('user wins')
user+=1
elif dic[b] == 'Gun':
print('its a tie')
else:
print('retry entry')
print('Game over', 'user:',user,'computer:',computer)
Are there any code examples left?
New code examples in category Python
-
Python 2023-04-11 03:04:20
-
Python 2022-03-27 22:40:04 pycharm no module named
-
Python 2022-03-27 22:25:05 assign multiple variablesin one line
-
Python 2022-03-27 22:20:02 levenshtein distance
-
Python 2022-03-27 21:35:09 get text from url python last slash
-
Python 2022-03-27 21:30:30 df concatenate df
-
Python 2022-03-27 21:25:09 python odd or even
-
Python 2022-03-27 21:15:32 python include function from another file
-
Python 2022-03-27 21:10:01 color module python
-
Python 2022-03-27 21:00:27 python tkinter cursor types