Learn to Code via Tutorials on Repl.it!

← Back to all posts
Die roll! (Python)
KyleWatson3

Hello everyone this is how to make a die roller in 🐍 🐍 Python !🐍 🐍

#Lets get started!
So first we’re gonna need randint so type this in a python repl:
from random import randint

Second, we are going to ask the user the size of the die:
sizeOfDie = input(“How many sides is the die?”)

And then we print the “roll”:
print(“Die roll: \n”) dieRoll = randint(1, sizeOfDie) print(dieRoll)

Bye y’all! Hope you enjoyed!

Voters
KyleWatson3
Comments
hotnewtop
KyleWatson3

So the full (readable) extended version of it is:

IntellectualGuy

This can be done in way less lines of code, here's my take

KyleWatson3

@IntellectualGuy Yes that is a faster way but i did that for readability

IntellectualGuy