Main content
Course: Intro to computer science - Python > Unit 3
Lesson 2: While loopsChallenge: Dice rolls
Instructions
Step 1
Repeat the experiment
Minh wrote a program that uses the random
module to roll two six-sided dice and then displays the dice total. Lucky! He rolled a 12 this time but wonders - what’s the average dice roll?
- Use a
while
loop to repeat Minh’s experiment 10 times.
The two dice should be rolled 10 times, and on each of the 10 rolls, the program should print the dice_sum
. You’ll need to add a loop variable to count to 10 rolls, and increment it on each loop iteration.