Robust programs · GCSE · OCR J277 2.5.2, AQA 8525 3.4.4, Edexcel 1CP2 6.1.5 · about 12 min
Editors, error diagnostics, the run-time environment and the translator, in the cell you use.
[1 mark]Which are IDE tools listed by OCR?
Tick every answer that is true.
[1 mark]How does syntax highlighting help a programmer?
[1 mark]What does stepping through a program in a debugger do?
[1 mark]Which IDE feature reports the line and type of an error?
This program should flash the LED three times, beeping each time, and then print flashed 3 times. It has a syntax error, a runtime error and a logic error. Use the squiggle, the error message and Debug to find and fix all three.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
flashes = 0
for i in range(3)
led("blue")
tone(660, 0.1)
wait(0.2)
led("off")
flashes = 1
print("flashed", flashs, "times")The hint students can ask for: There are three faults: one is a missing punctuation mark that ends a header line, one is a name spelled differently from where it was made, and one sets a counter instead of adding to it. The error messages point at the first two.
from bugbot import *
connect()
flashes = 0
for i in range(3):
led("blue")
tone(660, 0.1)
wait(0.2)
led("off")
flashes = flashes + 1
print("flashed", flashes, "times")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.