'F' → Fullscreen
Do it once, timed, on paper, in one sitting. A practice paper you dip into over three evenings with a computer open tells you nothing you did not already know.
This is revision, not homework. It is not collected and it is not graded. It also predicts your exam score better than anything else on this site.
22 questions, 2 points each, 44 points, 36 minutes. Pick one answer per question.
In exam notation, which line stores 7 in total?
total = 7total ← 77 ← totalIF(total = 7)In Lua, which operator asks whether two values are equal?
===←=>The exam writes a ≥ b. Lua writes the same test as:
a => ba >= ba > = ba greater b19 / 4 evaluates to:
44.753519 MOD 4 evaluates to:
44.753010 - 2 * 3 evaluates to:
244630In Lua, print("A") followed by print("B") produces:
A B on one lineAB on one lineA and B on separate linesprint may be called only onceRANDOM(2, 5) can return how many different values?
345In Lua, print("Score: " .. 7) displays:
Score: 7Score: "7"Score:7A student types 20 at a local n = io.read() prompt. The next line is if n > 15 then. Which line, added in between, makes that comparison work?
n = tostring(n)n = tonumber(n)n = "" .. nIn Lua, local xs = {1, 2} followed by print(xs[3] + 1) produces:
13niltonumber("3 apples") returns:
30nillocal t = {10, 20, 30}. The values of t[3] and #t are:
30 and 320 and 330 and 2nil and 3On the exam reference sheet, APPEND(aList, value):
value at index 1 and shifts everything rightvalue at the end and increases the length by 1valueaList aloneAfter this runs, nums[1] and LENGTH(nums) are:
nums ← [4, 5, 6]REMOVE(nums, 1)4 and 35 and 24 and 26 and 2After this runs, nums[1] and #nums are:
local nums = {4, 5, 6}table.remove(nums, 1)4 and 35 and 2nil and 26 and 3REPEAT 4 TIMES runs its body four times and:
iAfter this runs, count is:
x ← 1count ← 0REPEAT UNTIL(x > 6){ x ← x + 2 count ← count + 1}2346This displays:
local i = 10
repeat i = i + 1until i > 5
print(i)61011This displays:
a ← [1, 2, 3]b ← ab[1] ← 99DISPLAY(a[1])1993This displays:
local a = {1, 2, 3}local b = ab[1] = 99print(a[1])1993nilThe Create Performance Task requires at least one student-developed procedure. Which of these counts?
love.update(dt), because you filled it inmath.random(1, 6), because you chose the argumentsrollDice(sides), which you wrote and call yourselflove.graphics.circle, because it is in your programThree questions, 26 points, 19 minutes. Write in full sentences where the question asks you to explain something.
count ← 0i ← 1
REPEAT 3 TIMES{ j ← 1 REPEAT 4 TIMES { count ← count + 1 j ← j + 1 } i ← i + 1}DISPLAY(count)(a) How many times does the line count ← count + 1 run? (2 points)
(b) What does the program display? (2 points)
(c) Change exactly one number so that the display is 20, and explain why your change has that effect. (4 points)
local scores = {88, 92, 75}local total = 0
for i = 1, #scores + 1 do total = total + scores[i]end
print(total)(a) This program stops with an error. Explain what goes wrong and which value causes it. (4 points)
(b) Describe a change that removes the error without deleting the loop, and say what the program then prints. (4 points)
A list called temps holds any number of whole numbers.
In detailed steps, describe an algorithm that finds the largest number in the list and displays it. Write it so that somebody else could turn your description into working code without asking you a question.
You may write it in prose, in exam notation, or in Lua. Whichever you choose, your answer must make clear:
One per part of the quarter. Each one has the ideas, the traps, and the exam notation for its sessions — go to the one covering whatever you got wrong:
Everything below is fair game. Tick what you can do without looking:
← and = correctlyMOD gives you/ does not doif / elseif chainand, or, notwhile loopREPEAT UNTIL#t gives youreturn gives backNothing. This paper is not collected and it is not graded. Hand in the documentation sheet at the start of the exam period; that one is graded, and it is due on paper.