Six exam-style questions, weighted toward iteration. Four of them ask you to count passes, which is exactly what the exam's written questions do.
Set a timer for 10 minutes. On paper, no computer. Write out the passes in a column rather than doing them in your head — four rows is usually enough to see the answer, and it is faster than being wrong.
What does this print?
local w = 10local steps = 0
while w > 0 do w = w - 4 steps = steps + 1end
print(steps)234What does this display?
x ← 5passes ← 0REPEAT UNTIL(x > 10){ passes ← passes + 1 x ← x + 1}DISPLAY(passes)56100What does this print?
local c = 0
for i = 3, 7 do c = c + 1end
print(c)4573What does this print?
local hits = 0
for row = 1, 4 do for col = 1, 3 do hits = hits + 1 endend
print(hits)74123On the exam reference sheet, REPEAT n TIMES:
REPEAT UNTIL(n)n is 0Which of these can run their body zero times?
while in Luarepeat … until in Luafor i = 1, n do in Lua, when n is 0REPEAT UNTIL(condition) on the examOption D is the one worth thinking hardest about. The exam shares a word with Lua here and does not share the timing.
Six answers with sure or unsure beside each, and your time. For question 6, list every letter you chose.
Attach your pass tables for questions 1 to 4. The working is worth more than the answer, and on the exam it is what stops a careless slip.
Worth 4 points, graded on completion.