/ Projects / Python Turtle

Python Turtle Revision 🐢

Prepare for the assessment: Coordinates, Loops, Lists & Functions.

1 Theory & Coordinates 📐

1. The Grid System

Recall the Cartesian coordinate system used by Turtle.

2. Headings & Orientation

Match degrees to compass directions.

East (Right)
90°
180°
270°

3. Drawing Mechanics

1.
2.

2 Code Comprehension & Debugging 🐞

The code below is supposed to draw a blue pentagon. There are 4 errors. Find and fix them.

Buggy Code:

import turtle t = turtle.Turtle() t.colour("blue") # Error 1? # Draw a pentagon for i in range(5) # Error 2? t.forward(100) t.right(60) # Error 3? t.hideturtle() turtle.done()
Hint: A pentagon has 5 sides. The external angle is 360 / 5.

Your Corrected Code:

3 Coding Challenges ⌨️

Task A: The Starburst Pattern

Instructions:

  • The turtle must start at the center (0,0) for every line.
  • It must draw a line 100 pixels long, then return to the center.
  • It must change angle by 90 degrees after every line.
  • Crucial: You must use a for loop to iterate through the colour_list.
  • Use setheading or simple right/left turns.

Task B: Concentric Squares (Subprograms)

Write a program from scratch to draw Concentric Squares centered at (0,0).
Requirement 1 Define draw_centered_square(size, fill_color).
Requirement 2 Use penup() and goto() to center the shape (offset by size/2).
Requirement 3 Call function 3 times: Black (200), Red (150), Yellow (100).