Question: In the text ( on pp . 1 5 8 1 5 9 ) , we developed this function to draw fractal trees ( note
In the text on pp we developed this function to draw fractal trees note that some printings of the text contain a typo on pthe function name drawTree on the second and fourth lines from the top of the page should read fractalTree as shown in the corrected code below:
def fractalTreetrunkLength:
if trunkLength :
return
else:
turtle.forwardtrunkLength
turtle.left
fractalTreetrunkLength
turtle.right
fractalTreetrunkLength
turtle.left
turtle.backwardtrunkLength
This function draws trees with a fixed angle degrees always decreases their trunk length by a factor of and stops when trunkLength becomes less than
Your task is to write a more flexible function fractalTreeangle scale, trunkLength, levels fractalTree takes the angle as an argument. It also takes scale, which specifies an amount by which we multiply trunk length as we go from one level to the next ie if we set the scale to it will cut trunkLength in half at each level It also uses the variable levels to determine how many levels to go before stopping.
Here's an example:
fractalTree
If you would like to you can customize your recursive drawings with other features colors etc.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
