-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_14_dice_rolling_simulator.py
62 lines (54 loc) · 1.32 KB
/
project_14_dice_rolling_simulator.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
# Project 14
# Dice Rolling Simulator
# Step 1 - import random module
# Step 2 - defining a function to roll the dice
# Step 3 - create a dictionary that will have the values of the dice
import random
def roll_dice():
roll = input("Roll the dice? (Yes/No): ")
dice_drawings = {
1: (
" _______",
"| |",
"| 1 |",
"!_______!"
),
2: (
" _______",
"| |",
"| 2 |",
"!_______!"
),
3: (
" _______",
"| |",
"| 3 |",
"!_______!"
),
4: (
" _______",
"| |",
"| 4 |",
"!_______!"
),
5: (
" _______",
"| |",
"| 5 |",
"!_______!"
),
6: (
" _______",
"| |",
"| 6 |",
"!_______!"
)
}
while roll.lower() == "yes":
dice1 = random.randint(1, 6)
dice2 = random.randint(1, 6)
print("Dice rolled: {} and {}".format(dice1, dice2))
print("\n".join(dice_drawings[dice1]))
print("\n".join(dice_drawings[dice2]))
roll = input("\nRoll again? (Yes/No): ")
roll_dice()