I have a project for which I need to use turtle. I'm very new to python, and our teacher didn't really explain how to use turtle. What's the basic format I need to use to draw a polygon? I have to define a function, polygon(), and run it with two parameters as: polygon(sides, length). Do I import turtle first? Do I use for loops? I don't need someone to do the project for me; I just have absolutely no idea how turtle works and where to start. HELP please!!!!


Yes, you would need to import turtle. Here's a good place to start: docs.

And an excerpt from that site:

Because [turtle] uses Tkinter for the underlying graphics, it needs a version of python installed with Tk support.

So make sure you've got a more recent version of python.

Finally, a typical for loop:

for x in [1,2,3,4,5]:
    print x

Instead of a hard list you could use range(1,6) or better yet xrange(1,6); however the above example gives you a better idea of what's happening. Try typing that into your favorite Python interpreter to see what happens.

This question has already been answered. Start a new discussion instead.