Advertisement
programusy

Untitled

Mar 16th, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import turtle
  2.  
  3. def koch_curve(length, depth):
  4. if depth == 0:
  5. turtle.forward(length)
  6. else:
  7. for angle in [60, -120, 60, 0]:
  8. koch_curve(length / 3, depth - 1)
  9. turtle.left(angle)
  10.  
  11. length = 400
  12. depth = 4
  13.  
  14. turtle.penup()
  15. turtle.goto(-length / 2, 0)
  16. turtle.pendown()
  17. turtle.speed("fastest")
  18. turtle.hideturtle()
  19. for i in range(3):
  20. koch_curve(length, depth)
  21. turtle.right(120)
  22.  
  23. turtle.done()
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement