科勒曲线(课本)
import turtle import time def koch(size,n): if n==0: turtle.fd(size) else: for angle in[0,60,-120,60]: turtle.left(angle) koch(size/3,n-1) def main(): turtle.setup(600,600) turtle.speed(2) turtle.penup() turtle.goto(-200,100) turtle.pendown() turtle.pensize(2) level=5 koch(400,level) turtle.right(120) koch(400,level) turtle.right(120) koch(400,level) turtle.hideturtle() main() t=time.clock() print("Time Used:{}".format(time.clock()-t))
Time Used:8.444444444444446e-06
>>>