import turtle
def koch(size,n):
if n == 0:
turtle.fd(size)    #如果n=0画直线
else:
for angle in [0,60,-120,60]:  #n>0时直线不是直线,变成了-/\-这种形状
turtle.left(angle)
koch(size/3,n-1)    #从大数字变0
def main():
turtle.setup(600,600)
turtle.penup()
turtle.goto(-200,100)
turtle.pendown()
turtle.pensize(2)
level = 3
koch(400,level)
turtle.right(120)
koch(400, level)
turtle.right(120)
koch(400, level)
turtle.right(120)
turtle.hideturtle()
main()

相关文章:

  • 2021-07-02
  • 2021-04-12
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-06-29
猜你喜欢
  • 2021-12-20
  • 2021-10-17
  • 2021-10-17
  • 2022-02-10
  • 2021-09-02
相关资源
相似解决方案