Programming basics · GCSE · OCR J277 2.3.2, AQA 8525 3.2.11, Edexcel 1CP2 1.2.5 · about 15 min
Reading an error message, and the three kinds of error by their exam names.
[1 mark]print("hello" is missing its closing bracket. What kind of error is this?
[1 mark]A program runs with no error message, but the robot drives backwards when it should go forwards. What kind of error is this?
[1 mark]A program prints two lines, then crashes on print(10 / 0). What kind of error is this?
[1 mark]A program has a syntax error on its last line. How many of its lines run?
[1 mark]Which of these would stop the program with an error message?
Tick every answer that is true.
wait("two")prin("hi")forward(50, distance=30) when you meant 20stop with no brackets[1 mark]Put the steps for fixing an error in order.
Number the lines 1 to 4 to put them in the right order.
Read the error: find the kind and the line numberLook at that line, and the line above if it looks fineRun againChange one thingRead the error: find the kind and the line number Look at that line, and the line above if it looks fine Change one thing Run again
Change one thing at a time, so you know which change mattered.
This program should turn the LED green, wait a second, drive 30 cm forward into the green zone and print arrived. It has one syntax error, one runtime error and one logic error. Fix them one at a time.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
led("green"
wait("1")
backward(50, distance=30)
print("arrived")The hint students can ask for: One syntax error, one runtime error, one logic error. Fix the first error you are shown, run again, and watch where the robot goes.
from bugbot import *
connect()
led("green")
wait(1)
forward(50, distance=30)
print("arrived")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.