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.

Creative Code. Colourful Thinking.
Lesson 6
Find, explain and fix errors while improving creative Python outcomes.
Use these stages to move from reading code to creating your own version.
To debug creative Python code by reading errors, testing changes and improving output.
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.
Find the Bug
for i in range(4)
forward(100)
right(90)
Stretch: What shape should the corrected code draw?
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)
What is missing from the loop line?
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.
Debug by checking one likely problem at a time.
Are brackets, colons and quotation marks correct?
Are repeated commands indented?
Does the code run but draw the wrong pattern?
Introduce one deliberate bug, then fix it using a debugging checklist.
Improve a pattern and keep a short debugging note.
Fix a syntax error.
Fix a logic error in a pattern.
Debug and improve your own creative program.
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()
This WAGOLL shows a debugging process that explains the bug, fixes it, and tests the program again.
Explain what you learned and identify the next improvement you would make.
Create a debugging checklist that another student could use.
Why is testing one change at a time useful?