Exam-style question
Try this first
Consider this Python code: import random; value = random.randint(1, 3). Which statement is correct?.
- A.value can be 1, 2 or 3.
- B.value can be 1 or 2, but not 3.
- C.value can be 0, 1, 2 or 3.
- D.value is always 2.
Answer and explanation
Concise answer
value can be 1, 2 or 3.
Why this is correct
Both limits passed to randint are included, so the possible values are 1, 2 and 3.
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.
