tp d'informatique 04 octobre 2022

This commit is contained in:
Debucquoy
2022-10-06 16:13:06 +02:00
parent 53f5808f7f
commit 2c97733d86
10 changed files with 368 additions and 0 deletions

37
04oct/ex3.py Normal file
View File

@ -0,0 +1,37 @@
from uturtle import (
umonsTurtle, wait,
moveForward, moveBackward,
turnLeft, turnRight,
dropPen, usePen)
def koch(t: umonsTurtle, x: int, seuil: int):
"""Dessine une courbe de koch
:t: the turtle used
:x: the length
:seuil: seuil of smallest step
:returns: None
"""
if x < seuil:
moveForward(t, x)
return
koch(t, x/3, seuil)
turnLeft(t, 60)
koch(t, x/3, seuil)
turnRight(t, 120)
koch(t, x/3, seuil)
turnLeft(t, 60)
koch(t, x/3, seuil)
if __name__ == "__main__":
turtle = umonsTurtle()
turtle.speed(0)
dropPen(turtle)
moveBackward(turtle, 250)
usePen(turtle)
koch(turtle, 500, 1)
wait()