import turtle t = turtle.Turtle() t.speed(0) t.up() t.goto(0,-100) t.down() t.rt(-90) kat = 40 zmniejszanie = 0.7 def y(rozmiar, poziom): if poziom > 0: # drawing the base t.fd(rozmiar) t.rt(kat) # recursive call for # the right subtree y(zmniejszanie * rozmiar, poziom-1) t.lt( 2 * kat ) # recursive call for # the left subtree y(zmniejszanie * rozmiar, poziom-1) t.pencolor(255 - 255//poziom, 255//poziom, 255//poziom) t.rt(kat) t.fd(-rozmiar) # 9-cio poziomowe drzewo o rozmiarze 80 y(80, 9)