FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python/dice_rolling_simulator.py at master · wolfinwool/Python · GitHub
wolfinwool
/
Python
Public
forked from
geekcomputers/Python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Python
/
dice_rolling_simulator.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (62 loc) · 2.24 KB
Breadcrumbs
Python
/
dice_rolling_simulator.py
Copy path
File metadata and controls
94 lines (62 loc) · 2.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Made on May 27th, 2017
# Made by SlimxShadyx
# Editted by CaptMcTavish, June 17th, 2017
# Comments edits by SlimxShadyx, August 11th, 2017
# Dice Rolling Simulator
import
random
try
:
input
=
raw_input
except
NameError
:
pass
global
user_exit_checker
user_exit_checker
=
"exit"
# Our start function (What the user will first see when starting the program)
def
start
():
print
(
"Welcome to dice rolling simulator:
\n
Press Enter to proceed"
)
input
(
">"
)
# Starting our result function (The dice picker function)
result
()
# Our exit function (What the user will see when choosing to exit the program)
def
bye
():
print
(
"Thanks for using the Dice Rolling Simulator! Have a great day! =)"
)
# Result function which is our dice chooser function
def
result
():
# user_dice_chooser No idea how this got in here, thanks EroMonsterSanji.
print
(
"
\r
\n
Great! Begin by choosing a die! [6] [8] [12]?
\r
\n
"
)
user_dice_chooser
=
input
(
">"
)
user_dice_chooser
=
int
(
user_dice_chooser
)
# Below is the references to our dice functions (Below), when the user chooses a dice.
if
user_dice_chooser
==
6
:
dice6
()
elif
user_dice_chooser
==
8
:
dice8
()
elif
user_dice_chooser
==
12
:
dice12
()
# If the user doesn't choose an applicable option
else
:
print
(
"
\r
\n
Please choose one of the applicable options!
\r
\n
"
)
result
()
# Below are our dice functions.
def
dice6
():
# Getting a random number between 1 and 6 and printing it.
dice_6
=
random
.
randint
(
1
,
6
)
print
(
"
\r
\n
You rolled a "
+
str
(
dice_6
)
+
"!
\r
\n
"
)
user_exit_checker
()
def
dice8
():
dice_8
=
random
.
randint
(
1
,
8
)
print
(
"
\r
\n
You rolled a "
+
str
(
dice_8
)
+
"!"
)
user_exit_checker
()
def
dice12
():
dice_12
=
random
.
randint
(
1
,
12
)
print
(
"
\r
\n
You rolled a "
+
str
(
dice_12
)
+
"!"
)
user_exit_checker
()
def
user_exit_checker
():
# Checking if the user would like to roll another die, or to exit the program
user_exit_checker_raw
=
input
(
"
\r
\n
If you want to roll another die, type [roll]. To exit, type [exit].
\r
\n
?>"
)
user_exit_checker
=
(
user_exit_checker_raw
.
lower
())
if
user_exit_checker
==
"roll"
:
start
()
else
:
bye
()
# Actually starting the program now.
start
()
Back
|
FazBrowse Home
|
New Git URL