#KochDraw.py
import turtle //海龟绘图
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.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.hideturtle()
main()

成品:
科赫雪花利用python海龟绘图代码

相关文章:

  • 2022-12-23
  • 2021-10-17
  • 2021-07-17
  • 2021-11-28
  • 2021-10-23
  • 2021-04-12
  • 2021-04-06
  • 2022-12-23
猜你喜欢
  • 2021-07-02
  • 2021-06-05
  • 2021-10-25
  • 2021-08-13
  • 2021-09-05
  • 2021-11-11
相关资源
相似解决方案