-
Notifications
You must be signed in to change notification settings - Fork 0
/
user40_2D8rNhJ9tX_4.py
60 lines (49 loc) · 1.49 KB
/
user40_2D8rNhJ9tX_4.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
48
49
50
51
52
53
54
55
56
57
58
59
60
# CodeSkulptor runs Python programs in your browser.
# Click the upper left button to run this simple demo.
# CodeSkulptor runs in Chrome 18+, Firefox 11+, and Safari 6+.
# Some features may work in other browsers, but do not expect
# full functionality. It does NOT run in Internet Explorer.
import random
def name_to_number(name):
if name.lower() == 'rock':
return 0
elif name.lower() == 'spock':
return 1
elif name.lower() == 'paper':
return 2
elif name.lower() == 'lizard':
return 3
elif name.lower() == 'scissors':
return 4
else:
print("Sorry, that is not one of the choices")
#player_choice()
def number_to_name(number):
if number == 0:
return "rock"
elif number == 1:
return "Spock"
elif number == 2:
return "paper"
elif number == 3:
return "lizard"
elif number == 4:
return "scissors"
else:
print "Sorry, pick a number between 0 to 4"
def player_choice():
print("\n")
player_choice = input("Do you pick rock, scissors, paper, Spock, or lizard?")
player_number = name_to_number(player_choice)
print("Player chooses "+player_choice)
return player_number
def computer_guess():
print("\n")
comp_number = random.randrange(0,4)
comp_choice = number_to_name(comp_number)
print("Computer chooses "+comp_choice)
return comp_number
def game():
player_choice()
computer_guess()
game()