Skip to content

Instantly share code, notes, and snippets.

@sahilsinha
Created December 9, 2015 00:55
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 sahilsinha/4c3344a0b600e4d84218 to your computer and use it in GitHub Desktop.
Save sahilsinha/4c3344a0b600e4d84218 to your computer and use it in GitHub Desktop.
import turtle
def get_user_input():
userInput = raw_input("How many sides does your shape have?")
try:
userInput = int(userInput)
except:
print "Hey that's not a number!"
userInput = get_user_input()
return userInput
def drawPolygon (the_turtle,num_side):
angle = 360 / num_side
for iter in range (num_side):
the_turtle.forward (100)
the_turtle.left (angle)
def main():
turtle.setup (800, 800, 0, 0)
myturtle = turtle.Turtle()
sides = get_user_input()
drawPolygon(myturtle,sides)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment