(8/10)
Building A Dice Roller — Python typing lesson
Create a random dice roller using imported modules.
What you'll practice
Let's use another power from the `random` module to build a dice roller!
- `random.randint(a, b)` gives you a random whole number between `a` and `b` (inclusive).
- We use `randint(1, 6)` for a standard six-sided die.
Pro Access Required
This is a premium lesson. Upgrade to Pro to unlock this interactive exercise and continue your learning journey.
🐍Python
Building A Dice Roller
0 WPM
0% Accuracy
0:00 Time elapsed
1
2
3
4
5
6
7
import random↵
↵
print('You roll the dice...')↵
↵
roll = random.randint(1, 6)↵
↵
print('You rolled a ' + str(roll))
0 / 109
Press This!
👇
`~
1!
2@
3#
4$
5%
6^
7&
8*
9(
0)
-_
=+
⌫
⇥
Q
W
E
R
T
Y
U
O
P
[{
]}
\|
⇪
A
S
D
F
G
H
J
K
L
;:
'"
↵
⇧
Z
X
C
V
B
N
M
,<
.>
/?
⇧
Thumb
Index
Middle
Ring
Pinky