ajout sequence recursivité
This commit is contained in:
27
Recursivité/TP/TP_recursivite.py
Normal file
27
Recursivité/TP/TP_recursivite.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import turtle
|
||||
|
||||
def courbe_koch(n, l):
|
||||
if n == 0 :
|
||||
turtle.forward(l)
|
||||
else :
|
||||
courbe_koch(n-1, l/3)
|
||||
turtle.left(60)
|
||||
courbe_koch(n-1, l/3)
|
||||
turtle.left(-120)
|
||||
courbe_koch(n-1, l/3)
|
||||
turtle.left(60)
|
||||
courbe_koch(n-1, l/3)
|
||||
|
||||
def flocon(n,l,i=3):
|
||||
if i != 0:
|
||||
courbe_koch(n,l)
|
||||
turtle.left(-120)
|
||||
flocon(n,l,i-1)
|
||||
|
||||
turtle.setheading(0) # orientation intiale de la tête : vers la droite de l'écran
|
||||
turtle.hideturtle() # on cache la tortue
|
||||
turtle.speed(0) # on accélère la tortue
|
||||
turtle.color('green')
|
||||
#flocon(1,300)
|
||||
#courbe_koch(,400)
|
||||
print(8)
|
||||
Reference in New Issue
Block a user