logo

AQA A-Level Computer Science practice

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

Try the question first, then check the answer and practise the same topic again.

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.

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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions