Question: The random module can generate random numbers. One application is rolling a fair dice, which will produce a 1, 2, 3, 4, 5 or 6.

The random module can generate random numbers. One application is rolling a fair dice, which will produce a 1, 2, 3, 4, 5 or 6. The code below should explain how to generate random ints: > > > import random > > > for i in range (20): n = random.randint(1, 6) print (n, end ='') 4 4 1 3 1 3 2 5 3 1 4 5 4 5 6 1 3 3 2 4 > > > write a function, roll_dice(n), which returns the result of rolling n fair dice in a list. n is an int and is > =1. Sample run (your results will almost certainly be different from mine after a we are simulating dice rolls): for n in range (1, 7): print (roll_dice(n)) > > > [6] [6, 5] [2, 3, 6] [1, 6, 4, 3] [6, 3, 3, 1, 3] [1, 5, 2, 4, 1, 4] > > >
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
