The answersDownload the PDF
Worksheet

F13.7 Where marks are lost

Exam preparation · GCSE · about 15 min

BugBotLab
NameClassDate

What this lesson is about

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

Questions 5 marks in all

  1. [1 mark]Which is the commonest way to lose marks you knew?

    1. AAnswering the wrong command word
    2. BBad spelling
    3. CWriting too neatly
    4. DUsing a pencil
  2. [1 mark]What is wrong with setting a total to 0 inside a loop?

    1. AIt is reset every time round, so it never adds up
    2. BNothing
    3. CIt makes the loop slower
    4. DThe loop never ends
  3. [1 mark]if x = 5: will not run. Why?

    1. A= assigns; a comparison needs ==
    2. Bx must be a string
    3. CThere is no colon
    4. Dif needs brackets
  4. [1 mark]Which three values should you trace a program with?

    1. AA normal one, a boundary one and an invalid one
    2. BThree normal ones
    3. COnly the boundary
    4. DOnly what the question gives
  5. [1 mark]What does this program print?

    total = 0
    for n in range(1, 6):
        total = total + n
    print(total)

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

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/f13-7-where-marks-are-lost/
The simulator checks it and tells you when it passes. Nothing to install, no account.

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.