Back

Activity 1.26: Quarter 1 Practice Exam

divider

Activity 1.26

Quarter 1 Practice Exam

What This Page Is

A full-length practice paper, the same shape and length as the real one. Same number of questions, same split, same 55 minutes.

It is not graded and it is not the exam. It is the rehearsal.

The Shape of It

Section I — 22 multiple choice
44 points, 36 minutes. That is about 1:38 each, which is exam pace.
Section II — three written
26 points, 19 minutes. Trace a loop, find an error, describe an algorithm.

70 points. The real one is the largest single thing in the quarter.

The Reference Sheet Is on Your Desk

Same as May. Nothing on it needs memorizing — but you have to be able to find things on it quickly.

Everything else is closed. No notes, no code, no computer.

It Switches Notation Without Warning

Some questions are Lua. Some are exam notation. Nothing tells you which is coming.

That is deliberate, and it is the only honest rehearsal for meeting exam notation cold in May.

Assignment and Comparison

count ← count + 1
IF(count = 10)
{
DISPLAY(count)
}

stores. = asks. Lua writes those as = and ==, which is the reverse trap.

The Two Loops

REPEAT 5 TIMES
{
<block>
}
REPEAT UNTIL(x ≥ 10)
{
<block>
}

REPEAT UNTIL is the inverse of while — it repeats until the condition becomes true.

And REPEAT n TIMES gives you no counter. If you need one, you make it.

Lists

scores ← [12, 8, 21]
DISPLAY(scores[1])
DISPLAY(LENGTH(scores))
copy ← scores

First element is [1] in both. But copy ← scores copies, and Lua's version does not.

An out-of-range index terminates the program on the exam. In Lua it hands back nil and waits.

Procedures

PROCEDURE area(w, h)
{
RETURN(w * h)
}
kitchen ← area(3, 4)

PROCEDURE for both kinds. RETURN takes parentheses.

The Three That Catch People

  • A typed value is a string until tonumber
  • Assigning a table makes an alias in Lua and a copy on the exam
  • love.draw is not a student-developed procedure

Sessions 4, 19 and 23. All three are on the paper.

Good Luck

Twenty-five sessions ago you ran a program that printed one line.

Read every question twice. Answer the easy ones first.

'F' → Fullscreen

divider

How to Use This

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.

  • Print it or copy the answers onto a sheet. Writing them down is the point — the real paper is written on.
  • 36 minutes on Section I, then move, whether or not you have finished. Section II is 26 points and it is the half people under-plan for.
  • Reference sheet allowed. Nothing else. No notes, no code, no computer, no looking anything up.
  • Mark your own working, not just your answers. A question you guessed right is a question you got wrong.
The answers are not on this page, and that is deliberate. Your teacher has the key. Sit the paper first, then get it — a practice exam you can scroll the answers to is a reading exercise.

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.

divider

Section I — Multiple Choice

22 questions, 2 points each, 44 points, 36 minutes. Pick one answer per question.


1.

In exam notation, which line stores 7 in total?

  • (A) total = 7
  • (B) total ← 7
  • (C) 7 ← total
  • (D) IF(total = 7)

2.

In Lua, which operator asks whether two values are equal?

  • (A) =
  • (B) ==
  • (C)
  • (D) =>

3.

The exam writes a ≥ b. Lua writes the same test as:

  • (A) a => b
  • (B) a >= b
  • (C) a > = b
  • (D) a greater b

4.

19 / 4 evaluates to:

  • (A) 4
  • (B) 4.75
  • (C) 3
  • (D) 5

5.

19 MOD 4 evaluates to:

  • (A) 4
  • (B) 4.75
  • (C) 3
  • (D) 0

6.

10 - 2 * 3 evaluates to:

  • (A) 24
  • (B) 4
  • (C) 6
  • (D) 30

7.

In Lua, print("A") followed by print("B") produces:

  • (A) A B on one line
  • (B) AB on one line
  • (C) A and B on separate lines
  • (D) An error; print may be called only once

8.

RANDOM(2, 5) can return how many different values?

  • (A) 3
  • (B) 4
  • (C) 5
  • (D) Infinitely many, because the result is a decimal

9.

In Lua, print("Score: " .. 7) displays:

  • (A) Score: 7
  • (B) Score: "7"
  • (C) Score:7
  • (D) An error; text and numbers cannot be joined

10.

A 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?

  • (A) n = tostring(n)
  • (B) n = tonumber(n)
  • (C) n = "" .. n
  • (D) None; it already works

11.

In Lua, local xs = {1, 2} followed by print(xs[3] + 1) produces:

  • (A) 1
  • (B) 3
  • (C) nil
  • (D) The program stops with an error

12.

tonumber("3 apples") returns:

  • (A) 3
  • (B) 0
  • (C) nil
  • (D) An error

13.

local t = {10, 20, 30}. The values of t[3] and #t are:

  • (A) 30 and 3
  • (B) 20 and 3
  • (C) 30 and 2
  • (D) nil and 3

14.

On the exam reference sheet, APPEND(aList, value):

  • (A) Puts value at index 1 and shifts everything right
  • (B) Puts value at the end and increases the length by 1
  • (C) Replaces the last element with value
  • (D) Returns a new list and leaves aList alone

15.

After this runs, nums[1] and LENGTH(nums) are:

Exam notation
nums ← [4, 5, 6]
REMOVE(nums, 1)
  • (A) 4 and 3
  • (B) 5 and 2
  • (C) 4 and 2
  • (D) 6 and 2

16.

After this runs, nums[1] and #nums are:

Lua
local nums = {4, 5, 6}
table.remove(nums, 1)
  • (A) 4 and 3
  • (B) 5 and 2
  • (C) nil and 2
  • (D) 6 and 3

17.

REPEAT 4 TIMES runs its body four times and:

  • (A) Gives you a counter variable called i
  • (B) Gives you a counter variable you name in the header
  • (C) Gives you no counter at all
  • (D) Gives you a counter only if the body asks for one

18.

After this runs, count is:

Exam notation
x ← 1
count ← 0
REPEAT UNTIL(x > 6)
{
x ← x + 2
count ← count + 1
}
  • (A) 2
  • (B) 3
  • (C) 4
  • (D) 6

19.

This displays:

Lua
local i = 10
repeat
i = i + 1
until i > 5
print(i)
  • (A) 6
  • (B) 10
  • (C) 11
  • (D) Nothing; the loop never ends

20.

This displays:

Exam notation
a ← [1, 2, 3]
b ← a
b[1] ← 99
DISPLAY(a[1])
  • (A) 1
  • (B) 99
  • (C) 3
  • (D) An error; a list cannot be assigned to a list

21.

This displays:

Lua
local a = {1, 2, 3}
local b = a
b[1] = 99
print(a[1])
  • (A) 1
  • (B) 99
  • (C) 3
  • (D) nil

22.

The Create Performance Task requires at least one student-developed procedure. Which of these counts?

  • (A) love.update(dt), because you filled it in
  • (B) math.random(1, 6), because you chose the arguments
  • (C) rollDice(sides), which you wrote and call yourself
  • (D) love.graphics.circle, because it is in your program
divider

Section II — Written Response

Three questions, 26 points, 19 minutes. Write in full sentences where the question asks you to explain something.


23. (8 points) — Tracing a nested loop

Exam notation
count ← 0
i ← 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)


24. (8 points) — Finding a run-time error

Lua
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)


25. (10 points) — Describing an algorithm

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:

  • what holds the largest value found so far, and what it starts at
  • how you visit every element of the list
  • what the comparison is, and what happens when it is true
  • when the answer is displayed
divider

After You Have Sat It

Work Through the Section Summaries

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:

The Checklist

Everything below is fair game. Tick what you can do without looking:

  • Read and = correctly
  • Translate a Lua comparison into exam notation
  • Say what MOD gives you
  • Say what / does not do
  • Explain why a typed value is a string
  • Trace an if / elseif chain
  • Combine conditions with and, or, not
  • Count the passes of a while loop
  • Count the passes of a REPEAT UNTIL
  • Say what a nested loop does
  • Index a table from 1
  • Say what #t gives you
  • Say what a function with no return gives back
  • Say which procedures the Create Task counts

On the Day

  • Documentation sheet in your hand at the door. Not on a computer
  • Bring something to write with, and something to write with when that runs out
  • The reference sheet is provided. Nothing else
  • 36 minutes on Section I, then move — the written section is 26 points
divider

Submit

Nothing. 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.

Quarter Complete