sierpinski.py

Created by alain-busser

Created on May 16, 2022

431 Bytes

Dessin de la courbe de Sierpinski (1915). Projet mené en SNT (Seconde) durant l’année scolaire 2021-2022


from turtle import * 
def sierpinski(mot):
    global L
    for lettre in mot:
        if lettre in 'Dd':
            right(60)
            forward(L)
        else:
            left(60)
            forward(L)
suffixe = {'D': 'dDd', 'd': 'DGg', 'G': 'gGg', 'g': 'GDd'}

L = 1.4
mot = 'D'
for _ in range(6):
    nm = ''
    for lettre in mot:
      nm += suffixe[lettre]
    mot = nm
    print(mot)
sierpinski(mot)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.