Exam-style question
Try this first
What is the purpose of the following Python statement? random_number = random.randint(10, 20).
- A.It stores a random integer between 10 and 20 inclusive in random_number.
- B.It stores a random integer between 10 and 20 exclusive in random_number.
- C.It stores the number 10 in random_number and then increases it to 20.
- D.It stores the number of random numbers between 10 and 20 in random_number.
Answer and explanation
Concise answer
It stores a random integer between 10 and 20 inclusive in random_number.
Why this is correct
The randint function generates an integer in the specified inclusive range. The generated value is assigned to the variable random_number.
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.
