Exam-style question
Try this first
Write a Python program that simulates rolling a six-sided die once. The program must generate a random integer from 1 to 6 inclusive and display the result. Explain how your program meets the requirements.
Model answer
What a good answer should say
- import random roll = random.randint(1, 6) print(roll)
Explanation
Why this works
The random module is imported so that random number generation can be used. randint(1, 6) generates an integer with 1 and 6 included in the possible range, representing the result of one six-sided die roll.
The print statement displays the generated result.
Common mistake
No common mistake is linked to this question yet.
