from turtle import *
def koch(size,n):
if n==0:
fd(size)
else:
for angle in [0,60,-120,60]:
left(angle)
koch(size/3,n-1)
def main():
setup(800,400)
penup()
goto(-300,-50)
pendown()
pensize(2)
pencolor('red')
koch(600,3)
hidturtle()
done()
main()
三阶
from turtle import *
def koch(size,n):
if n==0:
fd(size)
else:
for angle in [0,60,-120,60]:
left(angle)
koch(size/3,n-1)
def main():