Rewrite short Lua programs in the notation the AP exam uses. No computer needed — this one works on paper, and doing it on paper is closer to the real thing.
You will never write this notation in a program. You only need to read it fluently, because that is what the multiple-choice section is made of. Translating in this direction is how reading gets easy.
Everything from the exam reference sheet that we have covered so far. Nothing else appears in these problems.
a ← expressionDISPLAY(expression)a + b a - ba * b a / ba MOD bRANDOM(a, b)Four rules that catch people:
local and there are no semicolons. A variable comes into existence the first time you assign to it... on the reference sheet. Nothing joins two strings together, which is exactly why one print can become two DISPLAY statements.local total = 12 + 8print(total)total ← 12 + 8DISPLAY(total)Two lines in, two lines out. Notice what disappeared: local and print.
Write the exam-notation version of each program. Line for line where you can.
local crewCount = 7print(crewCount)Careful with the last line. One print that glues a label onto a number with .. does not stay one statement.
local boxes = 47local perCrate = 6local leftOver = boxes % perCrateprint("Left over: " .. leftOver)Keep the parentheses. They mean the same thing in both notations.
local a = 9local b = 4local c = (a + b) * 2print("Result: " .. c)This one is already in exam notation. Write down exactly what it displays, in order.
x ← 17y ← 5DISPLAY(x / y)DISPLAY(x MOD y)Both answers are different numbers, and neither one is a whole-number division. Work them out by hand before checking.
print gives you two lines. DISPLAY does not — it puts a space after whatever it shows, so two of them in a row give you one line with a gap in the middle.Worth 3 points, graded on completion. Handwritten and photographed is fine, and is the closest thing to exam conditions.