Python exercises for ages 10+

Draw regular polygons

A regular polygon is a shape that is both equilateral (all sides have the same length) and equiangular (all inner angles are the same). In this exercise, we’ll draw these programmatically!

Part 1

Using the turtle library, draw a square where each side is 50 pixels long. Use a for loop to avoid code repetition. Each iteration of the for loop should draw one side of the square.

Part 2

Ask the user for a number of sides, and based on the number given, have your program draw any shape. Hint: the image below intuitively shows the relationship between the number of sides and the outer angle of rotation.

Proof for relationship between number of sides and outer angle for equilateral shapes

Extra