Last active
April 19, 2021 17:27
-
-
Save eloidrai/74bef045862fbd0659792549729e4695 to your computer and use it in GitHub Desktop.
Dessine une Courbe du Dragon. Prend 2 paramètres : le nombre d'itérations et la longueur d'un trait.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
iterations = int(input("Combien d'itérations ? ")) | |
longueur = int(input("Quelle longueur veux-tu pour un trait ? ")) | |
liste=["c"] | |
for i in range(iterations): | |
nouvelle_liste=[] | |
for pliage in range(0,len(liste)): | |
if pliage%2==0: | |
nouvelle_liste += ["m",liste[pliage],"c"] | |
else: | |
nouvelle_liste += [liste[pliage]] | |
liste=nouvelle_liste[:] | |
turtle.forward(longueur) | |
for tortue in liste: | |
if tortue == "m": | |
turtle.right(90) | |
turtle.forward(longueur) | |
if tortue == "c": | |
turtle.left(90) | |
turtle.forward(longueur) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment