← Quiz: Control Unit Design: all 10 questions
Quiz: Control Unit Design · Question 9 of 10
What does this print? (code)
What does this print?
CONTROL_MEMORY = {0: 1, 1: 2, 2: "map", 20: 21, 21: 0}
MAPPING = {"LOAD": 20}
car, trace = 0, []
for _ in range(5):
trace.append(car)
nxt = CONTROL_MEMORY[car]
car = MAPPING["LOAD"] if nxt == "map" else nxt
print(trace, car)
- A.[0, 1, 2, 3, 4] 5
- B.[0, 1, 2, 20, 21] 0
- C.[0, 1, 2, 20, 21] 22
- D.[0, 20, 21, 0, 1] 2
Answer & explanation
Correct answer: [0, 1, 2, 20, 21] 0
After the fetch steps 0–2, mapping jumps to 20; the LOAD routine ends by returning to 0.
Can you get the rest right without peeking?
Take the timed Quiz: Control Unit Design quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →