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.
Model answer
What a good answer should say
- It stores a random integer between 10 and 20 inclusive in random_number.
Explanation
Why this works
The randint function generates an integer in the specified inclusive range. The generated value is assigned to the variable random_number.
Common mistake
No common mistake is linked to this question yet.
