For this program, you need to make simulation that repeatedly rolls three 6-sided dice. You’ll be calculating how often the three dice all have different values. If you’ve taken a discrete math or probability course (by no means required!), you may have learned that the theoretical probability of obtaining three different values is
6 × 5 × 4 ≅ 0. 5556. This program will calculate the experimental probability of getting three different values for 63
rolling the three dice 10 times, 100 times, 1000 times, and 10000 times.
Consider the case when you roll the dice 10 times. Each time my while loop iterates, you want to roll all three dice once and answer the question “are these all different?”.
For this question you will use the random library.
To import the package:
# import the package and give it the nickname “rnd” import random as rnd
A few useful functions:
● rnd.randrange(min,max)-Generateandreturnarandomintegerfrommintomax-1 ● rnd.randint(min,max)-Generateandreturnarandomintegerfrommintomax
● rnd.random()-Generateandreturnarandomfloatfrom0.00to1.00
Hints:
● We recommend starting by writing a program that just does the simulation for 10 rolls.
● After you’ve done 10 rolls, then think about making the program do 100, 1000, etc. You’ll need to use a
nested while loop to achieve this. The outer loop will be in charge of indicating how many rolls are to be done (10 to 100 to 1000 to 10000). The outer loop would therefore iterate 4 total times. The inner loop will perform a single roll of the set of three dice and will itself iterate 10, 100, 100, 1000, and finally 10000, times.
● Think about what the value of 10 ** 1, 10 ** 2, etc is.