CODEKALEIDOSCOPE

Creative Code. Colourful Thinking.

Lesson 6

Lesson 6 of 8

Lesson 6 - Debugging Creative Code

Find, explain and fix errors while improving creative Python outcomes.

Do Now — 5 mins Theory — 10 mins I Do — 5 mins We Do — 10 mins You Do — 20 mins Plenary — 5 mins

Lesson Journey

Use these stages to move from reading code to creating your own version.

  1. Predict
  2. Run
  3. Investigate
  4. Modify
  5. Make

Learning Aim

To debug creative Python code by reading errors, testing changes and improving output.

Defined End Point

By the end of this lesson, you will be able to find, explain and fix errors in creative Python code, then improve the final output.

Key Vocabulary

debugsyntax errorlogic errortest

Do Now

Find the Bug

for i in range(4)
    forward(100)
    right(90)
  1. Can you spot the mistake?
  2. What error might appear?
  3. How would you fix it?
  4. Why is testing important?

Stretch: What shape should the corrected code draw?

Retrieval Practice

  • What is a string?
  • What is an integer?
  • What does a loop value control?

Theory

Predict which line will cause an error.

Read the code first. Do not run it yet.

from turtle import *

pencolor("cyan")
for i in range(6)
    circle(40)
    right(60)

Prediction question

What is missing from the loop line?

I Do

Watch the Demonstration

Watch how to read an error, fix one issue, then test again.

Type this corrected code into Mu Editor and run it.

from turtle import *

pencolor("cyan")
pensize(3)
speed(0)

for i in range(6):
    circle(40)
    right(60)

done()

Typing the code yourself helps build Python fluency and debugging skills.

We Do

Debug by checking one likely problem at a time.

Syntax

Are brackets, colons and quotation marks correct?

Indentation

Are repeated commands indented?

Logic

Does the code run but draw the wrong pattern?

You Do

Introduce one deliberate bug, then fix it using a debugging checklist.

Check spelling
Check punctuation
Check indentation
Check values

Workbook Activity

Improve a pattern and keep a short debugging note.

Bronze

Fix a syntax error.

Silver

Fix a logic error in a pattern.

Gold

Debug and improve your own creative program.

WAGOLL

Example code and output.

Use the example to connect the Python instructions with the visual result.

Example code

from turtle import *

pencolor("cyan")
pensize(3)
speed(0)

for i in range(6):
    circle(40)
    right(60)

done()

Example Output

This WAGOLL shows a debugging process that explains the bug, fixes it, and tests the program again.

Before debugging
After debugging

Plenary

Explain what you learned and identify the next improvement you would make.

Extension task

Create a debugging checklist that another student could use.

Plenary question

Why is testing one change at a time useful?

Lesson Hub←  PreviousNext  →