Created
December 9, 2015 00:58
-
-
Save sahilsinha/aba076126c196fffc59e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
def get_user_input(): | |
userInput = raw_input("What trick do you want to do?") | |
try: | |
userInput = str(userInput) | |
except: | |
print "That's not a trick!" | |
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() | |
trick = get_user_input() | |
if trick == 'square': | |
drawPolygon(myturtle,4) | |
elif trick == 'triangle': | |
drawPolygon(myturtle,3) | |
elif trick == 'octagon': | |
drawPolygon(myturtle,8) | |
else: | |
print "I don't know that trick'" | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment