Objective
Create a Python program that simulates dice rolls with the random module.
Instructions
- Import the
randommodule. - Read the number of rolls
n. - Simulate the
nrolls withrandom.randint(1, 6)and add up the results. - On the first line show
Rolls: n. - On the second show
Valid sum: V, whereVisTrueif the sum is betweennand6 · n(both included), andFalseotherwise. - Since the result is random, the exact sum is not shown: only whether it is valid.
10
Rolls: 10
Valid sum: True
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise