flocon_de_koch.py

Created by elodie-gamot

Created on October 29, 2021

340 Bytes

Flocon de Koch


from turtle import *

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

def flocon(l,n):
  penup()
  goto(-100,60)
  pendown()
  for i in range(3):
    cote(l,n)
    right(120)