Question 1 of 5
(a) List every possible value of RANDOM(4, 6). (b) How many distinct values is that? (c) Explain why running DISPLAY(RANDOM(4, 6)) twice may show two different numbers.
Responses receive AI feedback against a rubric after submission. Scores are practice estimates.
(a) List every possible value of RANDOM(4, 6). (b) How many distinct values is that? (c) Explain why running DISPLAY(RANDOM(4, 6)) twice may show two different numbers.
Code:
a ← RANDOM(1, 2)
b ← RANDOM(1, 2)
DISPLAY(a + b)
(a) List all possible values of a + b. (b) Show a counting argument for how many ordered pairs (a, b) exist. (c) Explain why 4 is possible but 0 is not.
A traffic light simulation sets colorCode ← RANDOM(1, 3) where 1 means red, 2 means yellow, and 3 means green. (a) How many distinct color codes are possible? (b) Why might two simulation runs show different first colors? (c) Give one impossible value for colorCode.
Expression: n ← RANDOM(0, 9) (a) How many distinct integers can n be? (b) Is 9 possible? Justify with inclusion of endpoints. (c) A student says the expression always displays 0 on the first run of a program. Refute with a one-sentence argument.
(a) Write an expression using RANDOM that can produce only the integers 5 and 6. (b) List those possible outcomes. (c) Explain what changes if the call becomes RANDOM(5, 7).