Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
406 B
2
Indexable
Never
import turtle

def koch_snowflake(length, depth):
    if depth == 0:
        turtle.forward(length)
    else:
        for angle in [60, -120, 60, 0]:
            koch_snowflake(length/3, depth-1)
            turtle.left(angle)

turtle.speed(0)
turtle.penup()
turtle.goto(-200, 100)
turtle.pendown()
for _ in range(3):
    koch_snowflake(400, 4)
    turtle.right(120)
turtle.exitonclick()