GCSE Computer Science

Python Turtle graphics โ€” GCSE Computer Science

What is Python Turtle?

Python Turtle is a built-in module that lets you draw shapes by moving a "turtle" around the screen. It's one of the best ways to learn programming because the output is visual โ€” you can see exactly what each line of code does. Move forward, turn, repeat. That's all it takes to draw almost anything.

Turtle is commonly used in GCSE Computer Science to teach loops and functions, because it shows the effect of repetition and abstraction in a way that's immediately obvious. A square drawn by copying four lines of code looks identical to a square drawn by a loop โ€” but the loop version scales. That's the point.

Loops with Turtle

import turtle

t = turtle.Turtle()

for i in range(4):
    t.forward(100)
    t.right(90)

This draws a square. The loop runs four times โ€” once for each side. t.forward(100) moves the turtle 100 pixels in the direction it's facing. t.right(90) turns it 90 degrees clockwise. Four sides, four turns. The key insight is that the loop body stays the same โ€” the turtle just starts each iteration pointing in a different direction. Change range(4) to range(6) and adjust the turn angle to 60, and you get a hexagon.

Functions with Turtle

import turtle

t = turtle.Turtle()

def draw_square(size):
    for i in range(4):
        t.forward(size)
        t.right(90)

draw_square(100)
draw_square(50)

Once a shape is wrapped in a function, you can draw it anywhere, any size, as many times as you want โ€” without repeating the code. This is what functions are for. draw_square(100) draws a large square. draw_square(50) draws a smaller one. The function takes a parameter so the size can vary, but the logic stays in one place. Examiners expect you to be able to read and write functions like this, and to explain why a function is better than copying the same code twice.

What examiners actually test

Turtle questions typically ask you to trace what a piece of code draws, write code to produce a specific shape, or adapt existing code to change a shape or add repetition. The most common errors are getting the turn angle wrong (remember: exterior angles for regular polygons add up to 360), forgetting to call the function after defining it, and confusing t.right() with t.left(). If you can draw a square, triangle, and hexagon using a loop, and wrap any of them in a function with a size parameter, you have covered the vast majority of what appears on GCSE papers.

Want structured Python lessons? Python Coach covers Turtle graphics, loops, functions and 24 other lessons with 195 challenges โ€” free 60 teaching day trial.

Start learning →