Random Values MCQ Practice

Question 1 of 10

How many distinct integers can RANDOM(1, 5) produce?

  1. A. 5
  2. B. 6
  3. C. 1
  4. D. 4

Question 2 of 10

Which outcome is impossible for RANDOM(2, 4)?

  1. A. 4
  2. B. 5
  3. C. 2
  4. D. 3

Question 3 of 10

A simulation runs die ← RANDOM(1, 6) on every trial. Why might two runs print different sequences of die values?

  1. A. Simulations are forbidden from calling RANDOM.
  2. B. RANDOM always returns the same integer on every call.
  3. C. Using random number generation means each execution may produce a different result.
  4. D. RANDOM ignores its arguments and prints text.

Question 4 of 10

Consider:

x ← RANDOM(0, 2)
y ← RANDOM(0, 2)
sum ← x + y

Which value of sum is impossible?

  1. A. 0
  2. B. 2
  3. C. 4
  4. D. 5

Question 5 of 10

RANDOM(a, b) includes both endpoints. What are the possible values of RANDOM(7, 7)?

  1. A. Only 7
  2. B. 6 and 7
  3. C. 7 and 8
  4. D. No values, because a equals b

Question 6 of 10

The table lists inclusive ranges and asks for the count of distinct outcomes.

Expression Distinct integers
RANDOM(1, 3) 3
RANDOM(5, 8) 4
RANDOM(10, 15) ?

What replaces the question mark?

  1. A. 5
  2. B. 6
  3. C. 15
  4. D. 10

Question 7 of 10

Code: coin ← RANDOM(0, 1). Which statement is true?

  1. A. coin can be 2
  2. B. coin can be -1
  3. C. coin can be 0 or 1, each possible on a given run
  4. D. coin is always 0

Question 8 of 10

A spinner simulation uses spin ← RANDOM(1, 4). A student claims the only possible display is 4 because the maximum was requested. What is wrong with that claim?

  1. A. RANDOM can return any integer without bound.
  2. B. RANDOM returns only even numbers in that range.
  3. C. Nothing; RANDOM always returns b.
  4. D. RANDOM(1, 4) can return 1, 2, 3, or 4 with equal likelihood.

Question 9 of 10

Which expression can produce the integer 0?

  1. A. RANDOM(0, 3)
  2. B. RANDOM(2, 6)
  3. C. RANDOM(10, 12)
  4. D. RANDOM(1, 5)

Question 10 of 10

How many distinct integers can RANDOM(3, 10) produce?

  1. A. 7
  2. B. 8
  3. C. 10
  4. D. 13