Modules and imports · 11 / 16 Exercise Medium

Six-sided die

Objective

Create a Python program that simulates dice rolls with the random module.

Instructions

  • Import the random module.
  • Read the number of rolls n.
  • Simulate the n rolls with random.randint(1, 6) and add up the results.
  • On the first line show Rolls: n.
  • On the second show Valid sum: V, where V is True if the sum is between n and 6 · n (both included), and False otherwise.
  • Since the result is random, the exact sum is not shown: only whether it is valid.
Input
10
Output
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