Drawing polygons in python turtle

Asaf Las roegltd at gmail.com
Tue Feb 11 01:34:19 CET 2014


On Tuesday, February 11, 2014 2:23:11 AM UTC+2, Asaf Las wrote:
> 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

just a bit add - confusing things here is the reference of 0 degree turtle 
takes to make turn from. i was also confused when so that (never tried 
turtle before). the 0 degree is the virtual line which is continuation 
of direction from point where forward(50) ends. so when left executes 
it should turn more than 180 to achieve 36 degrees and when right - 
less.

p.s. i am not good in explaining things. 



More information about the Python-list mailing list