Skip to content

Starburst

By the end of this lab you'll be able to:

  • Draw lines radiating outward from a single center point
  • Cycle through a color list using the modulo operator
  • Calculate how many lines are needed to fill a full 360° rotation

Thirty-six lines burst outward from the center, shifting in color from yellow to orange to red — like sunbeams caught mid-explosion.

Welcome to the Starburst!

Monty waving welcome In this lab you'll draw a line, back up to center, turn, and repeat — 36 times. The trick is that forward and backward together act like a two-way spoke. Let's code it together!

How the Burst Works

The turtle starts at the center. Each iteration: 1. Draws a line of length 150 outward (forward) 2. Returns to the center (backward the same distance) 3. Turns 10° clockwise (right(10)) before the next spoke

After 36 spokes: 36 × 10° = 360° — exactly one full rotation, filling the circle completely.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import turtle
monty = turtle.Turtle()
monty.speed(0)
monty.hideturtle()

colors = ['yellow', 'orange', 'red']
length = 150

for i in range(36):
    monty.color(colors[i % 3])
    monty.forward(length)
    monty.backward(length)
    monty.right(10)

What Do You Think Will Happen?

Monty thinking There are 3 colors and 36 spokes. How many red spokes will appear in the finished starburst? Make your guess — then click Run to find out!

Try It Now


  

36 ÷ 3 = 12 red spokes (and 12 yellow, 12 orange). Were you right?

How It Works

forward(length) moves Monty out from the center along the current heading. backward(length) brings Monty back to exactly the same starting point. right(10) rotates the heading 10° clockwise so the next spoke points in a new direction.

The color cycles because i % 3 produces 0, 1, 2, 0, 1, 2, … regardless of how large i grows.

Explanation Table

Line What it does
colors = ['yellow', 'orange', 'red'] Three-color gradient from warm to hot
length = 150 Length of each spoke in pixels
monty.color(colors[i % 3]) Cycles through the three colors evenly
monty.forward(length) Draws the spoke outward
monty.backward(length) Returns to center — no penup() needed
monty.right(10) 10° turn × 36 iterations = 360° full circle

Learning Check

Spot the Bug!

Monty warning The program below draws spokes but they don't fill the full circle — there's a gap! Find and fix the one wrong number so all 36 spokes spread evenly around 360°.


  

right(5) × 36 = only 180° — half a circle. Change it to right(10) for a full 360°.

Experiments

  1. Change spoke count. Replace range(36) with range(72) and right(10) with right(5). You'll know it worked when twice as many thinner spokes fill the circle.

  2. Use more colors. Change colors to ['yellow', 'gold', 'orange', 'darkorange', 'red', 'darkred'] and i % 3 to i % 6. You'll know it worked when the gradient has six distinct color bands.

  3. Make spokes different lengths. Replace length = 150 with length = 50 + i * 3. Early spokes are short; later ones are long. You'll know it worked when the starburst looks like a teardrop.

  4. Draw only every other spoke. Add if i % 2 == 0: before the forward line (and indent the next two lines). You'll know it worked when only 18 spokes appear with gaps between them.

Brilliant Work!

Monty celebrating You used forward + backward to draw spokes, modulo for color cycling, and math to prove that 36 × 10° = 360°. That's geometry AND Python in one program! Up next: Checkerboard Grid to explore nested loops and coordinate arithmetic.