logo

AQA A-Level Computer Science practice

Consider this Python code: import random; value = random.randint(1, 3). Which statement is correct?

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

Consider this Python code: import random; value = random.randint(1, 3). Which statement is correct?.

  1. A.value can be 1, 2 or 3.
  2. B.value can be 1 or 2, but not 3.
  3. C.value can be 0, 1, 2 or 3.
  4. 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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions