Tracing a Program by Hand · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Think it through on paper

Computing · Programming · ages 15-16
Name ______________________   Date ____________
  1. The computer stops at once and points at a line. Which error?

    • A logic error
    • A syntax error
    • A slow computer
  2. What does a trace table hold?

    • Only the final output
    • The list of keywords
    • Each variable's value at each line
  3. A logic error lets the program finish, but the answer is wrong.

    Circle one:   True   False

  4. A loop finishes quietly but totals 41 instead of 42. Which kind?

    • A syntax error
    • A logic error
    • A power cut
  5. A missing colon halts everything before anything runs. Which kind, and why?

    • Syntax, since the rules broke
    • Logic, since the answer is wrong
    • Neither, since colons are optional
  6. Where do you hunt first for a wrong-but-finished program?

    • Add more colons everywhere
    • Restart and hope
    • Trace the lines where values change
  7. Before running a short unknown program, what proves you grasp it?

    • Reading its title twice
    • A hand trace that predicts its printout
    • Counting its lines
  8. A friend blames line 9 for a crash flagged at line 4. What do you say?

    • Trust the flagged line, since syntax errors point at the confusion
    • Blame the last line of every program
    • Ignore messages and rewrite everything
LightMySky · lightmysky.comW1-mt__rsnZ5Goow-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Think it through on paper W1-mt__rsnZ5Goow-s1

  1. A syntax error · Broken grammar stops the run at once and points at the confusion.
  2. Each variable's value at each line · A trace table records what every name holds as each line runs.
  3. True · No rule broke, so nothing stops, yet the meaning drifted.
  4. A logic error · It ran start to finish, so grammar is fine and the meaning drifted.
  5. Syntax, since the rules broke · A missing colon breaks grammar, so nothing runs at all.
  6. Trace the lines where values change · Hand-tracing values shows where they first drift off track.
  7. A hand trace that predicts its printout · Predicting the printout on paper proves you followed every line.
  8. Trust the flagged line, since syntax errors point at the confusion · The flagged line is where the computer got lost, so start there.
Worksheet · LightMySky