Pliro – Code play. Build tomorrow.
Menu
Teaching materials and Classroom

PLIRO / Teaching material

Find bugs in code, one change at a time

A program can run and still draw something you did not intend. Start with a working square, deliberately change one turn and investigate how to repair it.

Ages 8–10 · after a first drawing lessonSuggested time: 30–45 minutesFree · No account needed
Start the working example

What you will practise

  • Compare an intended result with what the program actually does.
  • Suggest a cause before changing anything.
  • Test one change and explain why it helps.

What you need

  • An internet-connected device with an up-to-date browser.
  • Paper to record ‘expected’, ‘observed’ and ‘changed’.
  • Optionally, the Dutch Bug Detectives worksheet.

Preparation

  • Check that the starting program below draws a closed square.
  • Try changing right 90 to right 100 yourself.
  • The code below works; learners add the deliberate bug themselves.

Teaching material

Step by step

  1. Keep a starting point

    Open and run the program. You see a closed square. You can download the working source using the link under the example.

  2. Add a deliberate bug

    Choose Code, then Text. Change only right 90 to right 100. Leave everything else alone. Predict whether the shape will still close, then run it.

  3. Describe the difference

    The program turns 100 degrees four times: 400 degrees altogether, instead of a full turn of 360 degrees. The lines do not form a closed square.

  4. Test one repair

    Change the turn back to 90 and run again. Check the picture even when no error message appears. Running successfully is not the same as doing what you intended.

  5. Make a test for a classmate

    Ask a classmate to predict what forward 30 does instead of forward 60. It makes a smaller square and is not automatically a bug: your intention determines whether the result is right.

Try it yourself

This starting code works. Open the project, choose Code, then Text, to change something, then press Run.

Find bugs in code, one change at a time
# language: en

for side in [1, 2, 3, 4]:
    forward 60
    right 90

say "The shape is closed."

The example result

The working starting code and repaired version both draw a closed square. The version using right 100 shows why testing the result matters.

Discuss what you discovered

Explain ‘I intended …, I saw …, my test was …’. Allow different approaches that achieve the same result.

PDF

Extra material for this lesson

The bug detectives (PDF, in Dutch)

A next step

Make a first game

Make a first game