Where marks are lost

The ten commonest mistakes, checking on paper, and repairing a broken program.

F13.7Exam preparationGCSE15 min

Do this lesson in the simulator

Most lost marks are not lost to ignorance. They are lost to answering a different question, to stopping halfway, or to a slip that two seconds of checking would have caught. This lesson is the list of those mistakes, and a broken program to repair against the clock.

The ten that cost the most

  1. Answering the wrong command word. A "describe" answered with one word; an "explain" with no because.
  2. One point repeated. Four marks need four different points.
  3. Leaving it blank. An empty answer is certainly nothing; a reasonable attempt often is not.
  4. Ignoring the situation. The question names a hospital or a farm; the answer talks about computers in general.
  5. Vague words. "It is better", "it is faster", "more efficient" with no because.
  6. Stopping the program halfway. Later parts often need nothing from the earlier ones: write them anyway.
  7. Using the wrong units, or none. Bits against bytes, kB against MB, a number on its own.
  8. Off-by-one. A loop that runs once too often, a list index at the end, FOR 1 TO 5 against range(1, 5).
  9. Not reading the whole question. The last line often adds a condition, and the marks follow it.
  10. Running out of time. Long answers on a 1-mark question, then nothing written for an 8-mark one.
The lesson's ten mistakes sorted by when you can stop them: before, as and after you write, and across the paperbefore you write9read to the last line of the question1find the command word4note who the question is aboutas you write2a different point for each mark5say why, not just "better" or "faster"7a unit on every numberafter you write8trace loops for off-by-oneacross the paper10time by the marks3never leave a blank6write the later parts anywayred: its numberin the list
The same ten, sorted by the moment you can stop each one. Only one needs a check after you have finished; the rest are habits for before and while you write, and for the paper as a whole.

Checking a program on paper

You cannot run it in a written paper, so trace it (lesson F13.2) with:

  • a normal value;
  • the boundary: the first and last allowed;
  • something invalid.

If all three do what the question asked, you have almost certainly got the marks.

A number line with the allowed range marked, and the values to test: invalid below, the two boundaries, a normal value inside, invalid aboveallowedinvalidtoo smallboundaryfirst allowednormalin the middleboundarylast allowedinvalidtoo big
Three kinds of value, five points to try. The boundaries sit on the edges of what is allowed, which is exactly where a < written for a <= goes wrong.

The slips that break code

Slip What it looks like
= instead of == a comparison that assigns
counter set inside the loop it never grows past one
< where <= was meant the last item is missed
the variable name spelled two ways flashs and flashes
input not converted "5" + 1 fails, "9" > "10" is true
the check after the action validating a value you already used
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

# what the question asked for: the total of the numbers 1 to 5, and how many were odd
total = 0
odd = 0
for n in range(1, 6):           # 1 TO 5 means range(1, 6)
    total = total + n
    if n % 2 == 1:              # == compares; = would assign
        odd = odd + 1
print("total:", total, "odd:", odd)

Run this in the simulator

Task: repair the program

This program should drive 4 steps of 15 cm, printing step <n>: <total> cm after each one, then total: 60 cm and turn the LED green. It has three faults. Find them, fix them, and leave the rest alone.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

for step in range(1, 4):
    total = 0
    forward(50, distance=15)
    total = total + 15
    print(f"step {step}: {total} cm")
print(f"total: {total} cm")
led(255, 0, 0)

Challenges

  1. Which of the three faults would a trace table have caught first?
  2. Add a comment above each fix saying what was wrong.
  3. Pick two mistakes from the list of ten that you have made, and write how you will avoid each.