Skip to content

Instantly share code, notes, and snippets.

@dpritchett
Created November 15, 2010 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpritchett/700558 to your computer and use it in GitHub Desktop.
Save dpritchett/700558 to your computer and use it in GitHub Desktop.
Draw a polygon with an arbitrary number of sides using turtle graphics
import turtle
def drawPolygon(sides, fillcolor='DarkOliveGreen'):
init pen
turtle.reset()
turtle.fillcolor(fillcolor)
turtle.fill(True)
#draw a shape
degree = 360.0 / sides
for i in range(sides):
turtle.right(degree)
turtle.forward(degree)
turtle.fill(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment