Back

Question Set 2

Six questions · 10 minutes · cumulative through 1.12

divider

What This Is

Six exam-style questions, weighted toward booleans and decisions. Two are cumulative from set 1.

One question asks you to select all that apply. The real exam has eight of those in seventy, and they are marked the same way: every correct option and no incorrect ones.

Set a timer for 10 minutes. On paper, no computer, and mark each answer sure or unsure.


The Questions


Question 1

In exam notation, IF(a = b) asks whether:

  • (A) a is being assigned the value of b
  • (B) a and b are equal
  • (C) a is not equal to b
  • (D) Nothing; the exam requires ==

Question 2

In Lua, 5 ~= 5 evaluates to:

  • (A) true
  • (B) false
  • (C) nil
  • (D) An error; Lua uses !=

Question 3

What does this print?

Lua
local speed = 7
if speed > 10 then
print("fast")
elseif speed > 5 then
print("medium")
elseif speed > 0 then
print("slow")
else
print("stopped")
end
  • (A) fast
  • (B) medium
  • (C) slow
  • (D) medium and slow

Question 4

hp holds 0. What does this display?

Exam notation
IF(hp ≤ 0)
{
DISPLAY("Game over")
}
ELSE
{
DISPLAY("Keep going")
}
  • (A) Game over
  • (B) Keep going
  • (C) Both
  • (D) Neither

Question 5 — select all that apply

Which of these evaluate to true?

  • (A) 3 > 1 and 2 > 5
  • (B) 3 > 1 or 2 > 5
  • (C) not (3 > 1)
  • (D) 5 >= 5

Question 6

This is meant to move only on a or d. What actually happens?

Lua
local key = "x"
if key == "a" or "d" then
print("moving")
end
  • (A) Nothing prints; key is "x"
  • (B) moving prints, for any value of key
  • (C) An error, because "d" is not a condition
  • (D) moving prints only when key is "d"

Submit

Six answers with sure or unsure beside each, and your time. For question 5, list every letter you chose.

Worth 4 points, graded on completion.

Start the Timer