Head office, Rana Pratap Bagh, Delhi011 2721 1512+91 97116 99511

Science project idea

Python turtle spirograph of coloured circles

Python’s turtle module draws on a window. Drawing 72 circles with a 5 degree turn each time makes a spirograph, which shows how loops and angles create patterns.

What it shows

Python’s turtle module draws on a window. Drawing 72 circles with a 5 degree turn each time makes a spirograph, which shows how loops and angles create patterns.

The science

Turtle graphics moves a pen on the screen using forward, circle and right commands. Each circle starts where the turtle is and faces its heading, so turning 5 degrees between circles rotates the whole circle slightly. 72 turns of 5 degrees make 360, which closes the pattern. The modulo operator % picks colours from a list in a repeating order.

Materials

Cost: free. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.

  • A computer, laptop or phone with a browser (free)
  • Python 3 with IDLE, or the free Thonny editor, or an online Python runner (all free)
  • Turtle comes built in with Python, nothing extra to install

Safety

This project uses safe, everyday materials. Still, read the rules below with a parent before you start.

Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.

All the safety rules

Step by step

8 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.

  1. Create spiro.py and write import turtle on the first line.

  2. Make the pen with t = turtle.Turtle() and set t.speed(0) for the fastest drawing and turtle.bgcolor("black").

  3. Create a colour list: colours = ["red", "orange", "yellow", "green", "cyan", "blue", "magenta"].

  4. Start for i in range(72): and inside it write t.color(colours[i % 7]).

  5. On the next lines inside the loop write t.circle(100) and t.right(5).

  6. After the loop (not indented) write t.hideturtle() and turtle.done() so the window stays open.

  7. Run the program and watch the pattern appear; then change range(72) and t.right(5) to range(36) and t.right(10) for a looser pattern.

  8. Try t.forward(i * 3) with t.right(91) instead of the circle to draw a spiral.

What you should see

A black window shows 72 overlapping coloured circles forming a flower-like spirograph. Different numbers give different designs.

Viva questions

A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.

1Why 72 circles and 5 degrees?

72 times 5 equals 360, so the pattern completes one full turn.

2What does i % 7 do?

It gives the remainder when i is divided by 7, so the colour index cycles from 0 to 6.

3What does speed(0) mean?

It sets the fastest drawing speed.

4What does turtle.done() do?

It keeps the window open after the drawing ends.

Free ebook: Viva Questions for Science Projects

Take it further

Ask the user for the number of circles with input, calculate the turn angle as 360 divided by that number, and draw any pattern.

Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.

Free ebooks for this project

WhatsApp us