cours_progra/q1/04oct/ex2.py

29 lines
668 B
Python
Raw Normal View History

2022-10-06 16:13:06 +02:00
from uturtle import *
def triangle(t, n, size):
if n == 0:
moveForward(t, size)
turnLeft(t, 120)
moveForward(t, size)
turnLeft(t, 120)
moveForward(t, size)
turnLeft(t, 120)
else:
triangle(t, n-1, size/2)
moveForward(t, size/2)
triangle(t, n-1, size/2)
moveBackward(t, size/2)
turnLeft(t, 60)
moveForward(t, size/2)
turnRight(t, 60)
triangle(t, n-1, size/2)
turnLeft(t, 60)
moveBackward(t, size/2)
turnRight(t, 60)
if __name__ == "__main__":
t= umonsTurtle()
moveBackward(t, 250)
triangle(t, 5, 500)
wait()