logo

Question detail

What is the purpose of the following Python statement? random_number = random.randint(10, 20)

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

MCQ

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

What is the purpose of the following Python statement? random_number = random.randint(10, 20).

  1. A.It stores a random integer between 10 and 20 inclusive in random_number.
  2. B.It stores a random integer between 10 and 20 exclusive in random_number.
  3. C.It stores the number 10 in random_number and then increases it to 20.
  4. 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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.