snake water gun game in python

Solutions on MaxInterview for snake water gun game in python by the best coders in the world

showing results for - "snake water gun game in python"
Allen
04 Sep 2017
1# Snake water gun game in python 
2'''
3Snake vs. Water: Snake drinks the water hence wins.
4Water vs. Gun: The gun will drown in water, hence a point for water
5Gun vs. Snake: Gun will kill the snake and win.
6In situations where both players choose the same object, the result will be a draw.
7
8'''
9import random
10user = 0
11computer = 0
12turns = 0
13while (turns<10):
14    a = ['Snake','Water','Gun']
15    pc = random.choice(a)
16    print(pc)
17    turns +=1
18    dic = {1:'Snake',2:'Water',3:'Gun'}
19    b = int(input('1.Snake,2.Water,3.Gun'))
20    if b in dic:
21        print(dic[b])
22        if pc == 'Snake':
23            if dic[b] == 'Snake':
24                print('its tie')
25            elif dic[b] == 'Water':
26                print('PC wins')
27                computer +=1
28            elif dic[b] == 'Gun':
29                print('user wins')
30                user+=1
31                
32        elif pc == 'Water':
33            if dic[b] == 'Snake':
34                print('user wins')
35                user+=1
36            elif dic[b] == 'Water':
37                print('its tie')
38            elif dic[b] == 'Gun':
39                print('computer wins')
40                computer +=1
41         elif pc == 'Gun':
42            if dic[b] == 'Snake':
43                print('PC wins')
44                computer+=1
45            elif dic[b] == 'Water':
46                print('user wins')
47                user+=1
48            elif dic[b] == 'Gun':
49                print('its a tie')
50    else:
51        print('retry entry')
52
53print('Game over', 'user:',user,'computer:',computer)
54