-
Notifications
You must be signed in to change notification settings - Fork 0
/
dicegame.py
68 lines (55 loc) · 1.46 KB
/
dicegame.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
61
62
63
64
65
66
67
68
import sys
import random
def rolldice():
raw_input("Press 'enter' when ready")
a = random.randrange(1,6)
b = random.randrange(1,6)
c = random.randrange(1,6)
print a
print b
print c
dice = a + b + c
print "total %r" % (dice)
return dice
name = raw_input("What is your name?")
print "Hello %s, nice to meet you." % (name)
def playmod():
play = raw_input("Would you like to play a game?").lower()
if play == "yes" or play == "y":
print "Ok we can start playing now."
return
elif play == "no" or play == "n":
print "Thank you... Have a nice day..."
sys.exit(0)
else:
print "You didn't pick Yes or No... Please try again..."
playmod()
playmod()
print "The game works like this...\n"
print "There are 3 dice that will roll...\n"
print "We will both get a number...\n"
print "The one with the highest number wins...\n"
def myturn():
print "Rolling my dice!!!"
rolldice()
mydice = rolldice()
return mydice
def playerturn():
print "Rolling your dice!!!"
rolldice()
playerdice = rolldice()
return playerdice
def playgame():
myturn()
playerturn()
if myturn() > playerturn() :
print "I win"
sys.exit(0)
elif myturn() == playerturn():
print "Tie"
sys.exit(0)
else:
print "You win"
sys.exit(0)
playgame()
print playerdice