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.
Answer and explanation
Concise answer
import random roll = random.randint(1, 6) print(roll)
Why this is correct
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.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
