lesson

Find the first difference

1 · Learn

A bug is a problem in a program. To debug, compare what happened with what you intended. Trace one instruction at a time and find where they first differ.

Change a relevant part, then retest from the same starting state. If you also move the starting point, you may hide rather than fix the problem.

PredictRunCompareChangeRetest
Key words and supplied examples.

2 · Worked example

Goal: bell, pause, drum. Actual program: bell, drum, pause. I move the pause between the sounds and test again from the start.

3 · Your turn

A robot should move two squares, but its program says forward, forward, forward. What change should you test?

Check your answer

Remove the extra forward command, then run again from the same starting square and direction.

4 · Apply your learning

Ask a partner to trace your sound or movement program without running it. Compare their prediction with the actual result and explain any difference.

Adult guidance and safety

Use an adult-approved offline or school-managed application. Use invented data, original images and pretend identities. Paper models explain an idea but must be followed by suitable practical device work. Never enter real passwords or personal information in the working pad.

Open your writing and drawing pad

Write, draw or show your working. Use a mouse, pen or finger. This pad is not a submitted answer.

Not saved to your account. Download your drawing as PNG and your typed notes as TXT before leaving or refreshing. They are separate files. Do not enter private information.

Open a picture saved on this device to draw on it again. Opening replaces the drawing, but Undo can restore it. PNG only, up to 4 MB and 4096 × 4096 pixels. The picture stays in this browser; it is not uploaded. Paper lines in a saved picture become part of that picture.

Drawing is unavailable. Use the typed working area below.

Your pad is empty.

Open a UTF-8 TXT file from this device, up to 40 KB and 10,000 characters. It stays in this browser. Opening can be undone until you type again. Downloads keep a new copy; they do not change the file you opened.

Typed notes are not submitted answers.

Practice this lesson

Lesson resources

Browse the available practice activities and worksheets for this lesson.

Open course resources

Your progress

Ready to continue?