Fractals and recursion are two ideas that were made for each other. In videos 48-51, we will be exploring the ideas around fractals, recursive functions, and using randomization to make designs more interesting and realistic.
from turtle import *
import random
screen = Screen()
intMin = 30
def drawBranch(intDist, intLevel):
pensize((7-intLevel)*2+1)
intTravel = random.randint(int(intDist//1.5), int(intDist//.5))
forward(intTravel)
if (intDist > intMin):
left(30)
drawBranch(int(intDist//1.3), intLevel+1)
right(60)
drawBranch(int(intDist//1.3), intLevel+1)
left(30)
back(intTravel)
speed(0)
teleport(0,-200)
setheading(90)
drawBranch(150, 1)
screen.exitonclick()