Skip to content

Instantly share code, notes, and snippets.

@cotarg
Created December 3, 2014 20:43
Show Gist options
  • Save cotarg/3281221705e9b2afb672 to your computer and use it in GitHub Desktop.
Save cotarg/3281221705e9b2afb672 to your computer and use it in GitHub Desktop.
Use turtle to draw filled polygons.
import turtle
wn = turtle.Screen()
sides_num = input("How many sides should this polygon have? ")
sides_num = int(sides_num)
poly_color = input("What color should the outline of this polygon be? ")
fill_color = input("What color should this polygon be filled in? ")
polly = turtle.Turtle()
polly.color(poly_color)
polly.fillcolor(fill_color)
polly.fill(True)
for i in range(sides_num):
polly.forward(40)
polly.left(360/sides_num)
polly.fill(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment