Lesson 20 of 51 · Basic Shapes
Polygon (n-sides)
Any regular polygon uses the same formula.
Python
from turtle import *
bgcolor("black")
color("violet")
pensize(3)
speed(0)
sides = 6
length = 100
angle = 360 / sides
for i in range(sides):
forward(length)
right(angle)
done()Output

1
Universal Formula
For n sides: forward(length) then right(360 / n). Repeat n times.
2
Try Different Values
Change sides to 5, 6, 8, 12... see what happens!