Search⌘ K
AI Features

Challenge: Dice Roller

Explore how to create a dice roller in Python that simulates rolling two six-sided dice. Learn to use the random module, define and call functions, and handle multiple variables in this hands-on coding challenge.

We'll cover the following...

In this challenge, you’ll create a function that simulates rolling two six-sided dice. You’ll use Python’s random.randint() function to generate numbers between 1 and 6, just like a real die.

This will help you practice:

  • Using the random module.

  • Creating and calling functions.

  • Working with multiple variables.

Python
import random
# Update the code to make a function that rolls two dice.
die = random.randint(1, 6)
print("We rolled a", die)