''' Koch curve code from
http://openbookproject.net/thinkcs/python/english3e/recursion.html '''
import turtle
def koch(t, order, size):
''''This draws the Koch Curve, a fractal that starts with a line that is then
subdivided into 3 equal parts, and the subparts are then drawn recursively.'''
if order == 0:
t.forward(size) # base case does not call itself
else:
for angle in [60, -120, 60, 0]:
koch(t, order-1, size/3) # recursive call
t.left(angle)
def main():
''' the main function sets up a window and beings
the Koch curve of order given by the order.'''
wn=turtle.Screen()
tess=turtle.Turtle()
tess.penup()
tess.goto(-250,0)
tess.pendown()
order=int(raw_input("Enter small integer of Koch order desired: "))
koch(tess, order, 500)
wn.exitonclick()
main()