Assignment 9: Doing Assignment 9

Due by: Friday, November 17, 2023 at 11:59 p.m.

This assignment is an opportunity to play with the idea of recursion.

Specification

Nested Triangles

Write a recursive function called that draws a series of nested triangles, similar to the nestedBox() function given in listing 9.2 on page 288. You can adapt either the drawSquare() function from the same example or the drawTriangle() function from the Sierpinski example in listing 9.5 on page 294.

Include a call to your function that draws a nested triangle.

Your function should have the following header, where yertle is a turtle object and side is the length of at least one side of your triangle:

def nestedTriangle(yertle, side):

Parameterized Trees

Modify the tree function in listing 9.4 on page 290 so that the left and right angles and the left and right size reductions are parameters.

Include three calls to your function with different parameters that generate three trees that look different in interesting ways.

Your function should have the following header, where yertle is a turtle object, trunkLength is the initial length of the trunk, rightAngle is how much a right branch bends right, leftAngle is how much a left branch bends left, rightReduction is how much the length of a right branch is shortened, and leftReduction is how much the length of a left branch is shortened:

def parameterizedTree(yertle, trunkLength, rightAngle, leftAngle, rightReduction, leftReduction):

Extra Credit

Make a second modification of the original tree() function so that the number of branches is a parameter.

Include three calls to your function with different parameters that generate three trees that look different in interesting ways.

Your function should have the following header, where yertle is a turtle object, trunkLength is the initial length of the trunk, and branches is how many ways the tree should branch:

def branchingTree(yertle, trunkLength, branches):

Turn In

Upload assignment9.py to Blackboard.

All work must be submitted before Friday, November 17, 2023 at 11:59 p.m. unless you are going to use a grace day.

All work must be done individually. You may discuss general concepts with your classmates, but it is never acceptable for you to look at someone else's code. Please refer to the course policies if you have any questions about academic integrity. If you have trouble with the assignment, I am always available for assistance.

Grading

Your grade will be determined by the following weights:

Category Weight
Nested triangles 40%
Parameterized trees 60%
Branching trees 20%

Under no circumstances should any student look at the code written by another student. Tools will be used to detect code similarity automatically.