cours_progra/q1/04oct/ex5.py
2023-02-15 13:40:50 +01:00

29 lines
598 B
Python

from uturtle import (
umonsTurtle, wait,
moveForward, moveBackward,
turnLeft, turnRight,
dropPen, usePen)
def carre(t: umonsTurtle, x: int, seuil: int):
"""draw an alternative to koch witch is based on squares"""
if x < seuil:
moveForward(t, x)
return
carre(t, x/3, seuil)
turnLeft(t)
carre(t, x/3, seuil)
turnRight(t)
carre(t, x/3, seuil)
turnRight(t)
carre(t, x/3, seuil)
turnLeft(t)
carre(t, x/3, seuil)
if __name__ == "__main__":
turtle = umonsTurtle()
turtle.speed(0)
carre(turtle, 200, 5)
wait()