forked from accakks/Simple-Programs-in-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRockPaperScissors.py
50 lines (31 loc) · 928 Bytes
/
RockPaperScissors.py
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
#!/bin/python3
from random import randint
def rps():
playerCh = input('Choose rock, paper or scissors')
print('You chose '+playerCh)
computerCh = randint(1,3)
if computerCh == 1:
computerCh = 'rock'
print('Computer chose '+ computerCh )
elif computerCh == 2:
computerCh = 'paper'
print('Computer chose '+ computerCh )
else:
computerCh = 'scissors'
print('Computer chose '+ computerCh )
return(computerCh, playerCh)
c, p = rps()
if c == p:
print('Tie')
elif c == 'rock' and p == 'paper':
print('Player Wins')
elif c == 'rock' and p == 'scissors':
print('Computer Wins')
elif c == 'paper' and p == 'rock':
print('Computer Wins')
elif c == 'paper' and p == 'scissors':
print('Player Wins')
elif c == 'scissors' and p == 'rock':
print('Player Wins')
elif c == 'scissors' and p == 'paper':
print('Computer Wins')