Module 1 · Learning to Drive
Lesson 5 · The Polygon Function — Knowledge ChecksAnswer key
What turn angle will polygon compute for a 12-sided shape (a dodecagon)?
The function calculates 360 ÷ 12 = 30° on its own — no need to work it out by hand.
polygon (8, 25) traces an octagon about 2 m around. What does polygon (8, 50) do?
Doubling side_length doubles each side, so the perimeter doubles — but the angles (and therefore the shape) stay the same.
Without a general polygon function, you'd write one function each for square, triangle, pentagon, hexagon, and octagon. With polygon, how many functions do you need?
That's the power of generalizing: a single well-designed function replaces all the special-case ones.