vonkoch2.py

Created by bilouclic

Created on October 10, 2024

1.16 KB


import turtle as tl

def courbeVonKoch(  n, cote  ) :
  if n == 0 :
    tl.forward(cote)
  else :
    courbeVonKoch(n-1, cote/3)
    tl.left(60)
    courbeVonKoch(n-1, cote/3)
    tl.right(120)
    courbeVonKoch(n-1, cote/3)
    tl.left(60)
    courbeVonKoch(n-1, cote/3)

tl.setheading(0) # orientation intiale de la tête : vers la droite de l'écran
tl.hideturtle() # on cache la tortue
tl.speed(0)   # on accélère la tortue
tl.color('green')
courbeVonKoch(  n = 3, cote = 200  )
tl.exitonclick() # pour  garder ouverte la fenêtre

import turtle as tl

def courbeVonKoch(  n, cote  ) deux point
  if n == 0 :
    tl.forward(cote)
  else :
    courbeVonKoch(n-1, cote/3)
    tl.left(60)
    courbeVonKoch(n-1, cote/3)
    tl.right(120)
    courbeVonKoch(n-1, cote/3)
    tl.left(60)
    courbeVonKoch(n-1, cote/3)


def flocon(n, cote) :
  for _ in range(3) :
    courbeVonKoch(  n, cote  )
    tl.right(120)

tl.setheading(0) # orientation intiale de la tête : vers la droite de l'écran
tl.hideturtle() # on cache la tortue
tl.speed(0)   # on accélère la tortue
tl.color('green')
flocon(  n = 3, cote = 200  )
tl.exitonclick() # pour  garder ouverte la fenêtre


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.