Color-Banded Pentagon Spiral¶
By the end of this lab you'll be able to:
- Create a pentagon spiral using
right(72)— the exterior angle of a regular pentagon - Produce diagonal color bands by choosing a banding interval that doesn't divide evenly into the pentagon period
- Predict how the period of banding interacts with the polygon period to create visual patterns
A pentagon spiral with five-sided corners — colored in bands of five hues that cut diagonally across the arms because 5 colors × 5-sided spiral = aligned bands, while non-multiple intervals create diagonal stripes.
Welcome to the Pentagon Spiral!
This lab is the last in our spiral series — and it brings together everything:
polygon angles, color banding with i // n, and the interaction between two periods.
Let's code it together!
How It Works¶
A regular pentagon has 5 sides with exterior angles of 360° ÷ 5 = 72°. Turning 72° each step creates a pentagon spiral.
For color bands, (i // 5) % 5 changes color every 5 steps — matching the pentagon period exactly. This makes each band align with one full spiral side. Try (i // 7) % 5 instead and the bands shift diagonally!
Sample Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
What Do You Think Will Happen?
The color changes every 5 steps and the pentagon has 5 sides per revolution.
Will the color bands align with the spiral arms, or cut diagonally across them?
Make your guess — then click Run to find out!
Try It Now¶
The bands align with the arms — each arm is a single color because the band period (5) matches the polygon period (5). Were you right?
How It Works¶
When the color band interval evenly divides the polygon period, colors align with sides. When they don't match — for example, using 7 steps per color band on a 5-sided spiral — the bands appear to cut diagonally across the arms, creating the visual effect of diagonal stripes.
Explanation Table¶
| Line | What it does |
|---|---|
right(72) |
Pentagon exterior angle: 360° ÷ 5 = 72° |
(i // 5) % 5 |
Change color every 5 segments; cycle through 5 colors |
step += 1.2 |
Grow step — source of the spiral |
range(250) |
250 steps = 50 "pentagon" revolutions (5 sides each) |
Learning Check¶
Your Turn — Create Diagonal Bands
Change i // 5 to i // 7. Now the color period (7) doesn't divide evenly into the
pentagon period (5). Predict how the bands will change — then run it to check!
With i // 7, the color boundaries no longer align with the pentagon corners — they cut across the arms at a diagonal, producing a striped weave effect across the spiral.
Experiments¶
-
Try
i // 3. Three steps per band is shorter than one pentagon side (5 steps). You'll know it worked when colors change within each arm, creating a finer striped pattern. -
Use 3 colors instead of 5. Change the list to
['crimson', 'gold', 'royalblue']and% 5to% 3. You'll know it worked when only three colors appear, cycling in a non-aligned pattern. -
Make it hexagonal. Change
right(72)toright(60)andrange(250)torange(300). You'll know it worked when corners become less sharp. -
Increase band width. Change
i // 5toi // 15. Each color occupies 3 full pentagon sides. You'll know it worked when the color bands are much wider.
Category Complete!
You've mastered all 10 spiral patterns — from simple square to logarithmic to double helix!
Each spiral used the same core idea but with subtle variations that transformed the result.
Up next: Category 4 — Fractals and Recursion!