-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrps_sim.py
40 lines (28 loc) · 922 Bytes
/
rps_sim.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
"""Rock
Paper
Scissors"""
from random import randint
options = ["ROCK", "PAPER", "SCISSORS"]
message = {"tie":"Yawn it's a tie!",
"won":"Yay you won!",
"lost":"Aww you lost!"}
def decide_winner(user_choice, computer_choice):
print user_choice
print computer_choice
if user_choice == computer_choice:
print message["tie"]
elif user_choice == options[0] and computer_choice == options[2]:
print message["won"]
elif user_choice == options[1] and computer_choice == options[0]:
print message["won"]
elif user_choice == options[2] and computer_choice == options[1]:
print message["won"]
else:
print message["lost"]
def play_rps():
#print "Rock, Paper or Scissors?"
user_choice = options[randint(0, 2)]
user_choice = user_choice.upper()
computer_choice = options[randint(0, 2)]
return decide_winner(user_choice, computer_choice)
play_rps()