/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/lab-111-021/main.py
36 строк
898 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
def koch_curve_string(iterations: int) -> str: s = "F" for _ in range(iterations): s = s.replace("F", "F+F--F+F") return s def draw_koch_snowflake(side: float, iterations: int = 3): t = turtle.Turtle() t.speed(0) instr = koch_curve_string(iterations) scale = side / (3 ** iterations) t.penup() t.goto(-side / 2, -side / (2 * math.sqrt(3))) t.pendown() t.setheading(0) for c in instr: if c == "F": t.forward(scale) elif c == "+": t.left(60) elif c == "-": t.right(60) # Замыкание в снежинку for _ in range(2): for c in instr: if c == "F": t.forward(scale) elif c == "+": t.left(60) elif c == "-": t.right(60) t.right(120) t.hideturtle()