Created
December 5, 2018 13:24
-
-
Save eloidrai/e997ccedbbd528b80e798302484314a6 to your computer and use it in GitHub Desktop.
Dessine un Flocon de Koch. 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 = ["m","m","m"] | |
for i in range(iterations): | |
nouvelle_liste = [] | |
for creation in liste: | |
nouvelle_liste += [creation,"c","m","c"] | |
liste = nouvelle_liste[:] | |
t = turtle.Pen() | |
for tortue in liste: | |
t.forward(longueur) | |
if tortue == "m": | |
t.right(120) | |
else: | |
t.left(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment