Drawing polygons in python turtle

Asaf Las roegltd at gmail.com
Mon Feb 10 19:23:11 EST 2014


On Tuesday, February 11, 2014 1:44:28 AM UTC+2, geni... at gmail.com wrote:
> Hi
> 
> can anyone help finding the angle to draw different polygons shapes
> in this example 
> import turtle 
> wm = turtle.Screen()
> alex = turtle.Turtle()
> for i in range(5):
>     alex.left(216)
>      alex.forward(50)
> wm.exitonclick() 
> Why do we use 216

because of every for every turn we need to make angle between edges 
equal to 36. If you will have a look to pentagon definition:
http://en.wikipedia.org/wiki/Pentagon
inner angle is equal to 108. from that you can easily calculate 
the angle between edges of star. 
there is no difference between these 2: 

alex.left(216)
alex.right(144)

change left() to right() and see.

/Asaf



More information about the Python-list mailing list