Robust programs · GCSE · OCR J277 2.3.2, AQA 8525 3.2.11, Edexcel 1CP2 6.1.2 · about 15 min
Finding the mistake that gives no message: watching, printing, stepping and common bugs.
[1 mark]What is the first step in finding a logic error?
[1 mark]A loop meant to run four times uses range(3). What kind of bug is this?
[1 mark]Why change only one thing at a time when debugging?
[1 mark]Which help find where a logic error first appears?
Tick every answer that is true.
[1 mark]What does this program print?
total = 0
for x in [4, 6]:
total = 0
total = total + x
print(total)This program should drive a square of 25 cm sides clockwise, turning right at each corner, and finish back at the start, facing the way it began. It has three logic errors. Find them with the trail, prints or Debug, and fix them one at a time.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
side = 25
for i in range(3):
side = 20
forward(60, distance=side)
turn_left(30, angle=90)Plan your program here, then type it in and press Run.
print that shows a variable's value and its type. When would the type be the clue?