This task is part of project03 which is due at 23:00 EDT on 2024-09-24.
You have the option to work with a partner on this task if you wish. Working with a partner requires more work to coordinate schedules, but if you work together and make sure that you are both understanding the code you write, you will make progress faster and learn more.
You can download the starter code for this task using this link.
You can submit this task using this link.
Put all of your work for this task into the file
treeParts.py
(which is provided among the starter files)
For this problem set, you have a choice: you may complete this task OR
the musicalMeasures task, but you do not need to complete both. treeParts
(this task) is graphics-oriented and works with turtle
graphics, while
musicalMeasures is
based on audio and music instead, using the wavesynth
library.
This task will help you practice the material on custom functions and how to use several functions together to achieve a complicated result.
In this task, your ultimate goal is to draw leaves, twigs, branches, and ultimately trees, like these ones:
You will accomplish this task by completing several subtasks. You should do these subtasks in order.
You are free to design your tree however you'd like: your functions may
use parameters or not, and may or may not have return values. However,
there are two restrictions: each function must draw something, and except
for main
, they must each move the turtle back to wherever it
started when the function was called.
leaf
The leaf
function has been provided for
you, but you are free to modify it, including by changing the number of
parameters used, what it draws, or the return value. The provided leaf
function illustrates one strategy for returning the turtle to where it
started: after drawing what you
want to draw, move backwards retracing your steps to get back to where
you started.
It does still need to draw something.
twig
The twig
function must draw
something, and must call leaf
at
lest twice. As with leaf
, it
must put the turtle back where it started when it's
done..
The first example shows how the twig
function could
work, but remember that you're free to have it draw whatever you want,
and you do not have to stick to the suggested parameters or return value.
branch
Just like the twig
function, the branch
function must:
Also, it must call either left
or right
to turn the turtle at some
point.
This example shows one way the branch
function
could work.
tree
The tree
function must:
branch
at least twice,left
or right
to turn the turtle at some
point.This example shows one way the tree
function
could work.
main
Because you're free to design your tree
function with any number of
parameters, there's now way for us to call your tree
function directly.
To solve this issue, you must define a main
function which has zero parameters and
which calls your tree
function at least
once. Unlike the other functions,
the main
function does not need to call any drawing functions directly.
It must complete without crashing, however.
We recommend adding a call to your main
function at the end of your
file so that it will be called every time you run the file.
This example shows one way the main
function
could work.
We have provided a file named test_treeParts.py
which can be used
to check some of the constraints specified above, but you should rely on
Potluck for thorough testing. We recommend that you test each function as
you build it, because the lessons you learn from debugging your earlier
functions will help you improve the later functions.
If you want to test that you are returning to the starting position for
the twig, branch, and tree functions, follow the instructions in
test_treeParts.py
to fill in the required example functions and
uncomment the extra testing call at the end of that file.
We recommend you use noTrace
and showPicture
to speed up drawing,
although turning them off while debugging can also be informative.
Twig
This example shows what the twig function might draw, print, and return (note that your twig function does not have to be fruitful). Note that when the function is finished, the turtle is positioned back at the base of the twig, in the same place (and oriented in the same direction) that it started in. This is true for the following examples as well.
In []:Prints# Draw the twig: top = twig(10, 100, 'Sienna', 'SpringGreen2') # Show the turtle's position (it's back at the start) color('black') stamp()
A 10-pensize Sienna horizontal line from (0, 0) to (100, 0). Start of filled shape. A 2-pensize SpringGreen2 ellipse centered at (123, 9) with a 25-unit major axis at 20° and a 16.7-unit minor axis Filled in shape using SpringGreen2. Start of filled shape. A 2-pensize SpringGreen2 ellipse centered at (123, -9) with a 25-unit major axis at 160° and a 16.7-unit minor axis Filled in shape using SpringGreen2.Out[]:Image232
Branch
This example shows what the branch function might draw, print, and return. As with the twig, your function does not need to return anything. Note how the turtle returns to where it started even though it did not start at the origin.
In []:Prints# First, rotate a bit and back up lt(25) leap(-60) # Draw the branch: top = branch(12, 80, 50, 'Wheat4', 'DarkOliveGreen2', 'LightGray') # Show the turtle's position (it's back at the start) color('black') stamp()
A 12-pensize Wheat4 25° line from (-54, -25) to (18, 8). A 12-pensize Wheat4 65° line from (18, 8) to (39, 54). Start of filled shape. A 2-pensize DarkOliveGreen2 ellipse centered at (40, 66) with a 12.5-unit major axis at 85° and a 8.3-unit minor axis Filled in shape using DarkOliveGreen2. Start of filled shape. A 2-pensize DarkOliveGreen2 ellipse centered at (48, 63) with a 12.5-unit major axis at 45° and a 8.3-unit minor axis Filled in shape using DarkOliveGreen2. A 12-pensize Wheat4 25° line from (18, 8) to (63, 30). Start of filled shape. A 2-pensize DarkOliveGreen2 ellipse centered at (72, 38) with a 12.5-unit major axis at 45° and a 8.3-unit minor axis Filled in shape using DarkOliveGreen2. Start of filled shape. A 2-pensize DarkOliveGreen2 ellipse centered at (76, 31) with a 12.5-unit major axis at 5° and a 8.3-unit minor axis Filled in shape using DarkOliveGreen2. A 12-pensize Wheat4 165° line from (18, 8) to (66, -4). Start of filled shape. A 2-pensize DarkOliveGreen2 ellipse centered at (79, -3) with a 12.5-unit major axis at 5° and a 8.3-unit minor axis Filled in shape using DarkOliveGreen2. Start of filled shape. A 2-pensize DarkOliveGreen2 ellipse centered at (77, -12) with a 12.5-unit major axis at 145° and a 8.3-unit minor axis Filled in shape using DarkOliveGreen2. Start of filled shape. A 2-pensize LightGray ellipse centered at (24, 11) with a 6.8-unit major axis at 25° and a 4.5-unit minor axis Filled in shape using LightGray. Start of filled shape. A 2-pensize LightGray ellipse centered at (23, 4) with a 6.8-unit major axis at 133° and a 4.5-unit minor axis Filled in shape using LightGray. Start of filled shape. A 2-pensize LightGray ellipse centered at (15, 3) with a 6.8-unit major axis at 61° and a 4.5-unit minor axis Filled in shape using LightGray. Start of filled shape. A 2-pensize LightGray ellipse centered at (11, 10) with a 6.8-unit major axis at 169° and a 4.5-unit minor axis Filled in shape using LightGray. Start of filled shape. A 2-pensize LightGray ellipse centered at (17, 15) with a 6.8-unit major axis at 97° and a 4.5-unit minor axis Filled in shape using LightGray. Start of filled shape. A 2-pensize LightGray circle centered at (18, 8) with radius 3.4 Filled in shape using LightGray.Out[]:Image261
Tree
This example shows what the tree function might draw, print, and return. Once again, your result value doesn't have to be like this, and you don't need a return value at all if you don't want one. Notice that the turtle's final position (indicated by the black stamp) is the same as its starting position.
In []:Prints# Setup teleport(0, -140) left(85) # Draw the tree tree(18, 210, 140, 60, "Chocolate4", "Chartreuse2", "red") # Show the turtle's position (it's back at the start) color('black') stamp()
A 18-pensize Chocolate4 85° line from (0, -140) to (18, 69). A 9-pensize Chocolate4 25° line from (18, 69) to (145, 128). A 9-pensize Chocolate4 65° line from (145, 128) to (171, 183). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (172, 198) with a 15-unit major axis at 85° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (181, 193) with a 15-unit major axis at 45° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 25° line from (145, 128) to (200, 154). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (210, 164) with a 15-unit major axis at 45° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (215, 155) with a 15-unit major axis at 5° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 165° line from (145, 128) to (203, 113). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (218, 114) with a 15-unit major axis at 5° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (215, 104) with a 15-unit major axis at 145° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize red ellipse centered at (153, 132) with a 8.1-unit major axis at 25° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (151, 122) with a 8.1-unit major axis at 133° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (141, 121) with a 8.1-unit major axis at 61° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (137, 130) with a 8.1-unit major axis at 169° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (144, 136) with a 8.1-unit major axis at 97° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red circle centered at (145, 128) with radius 4.1 Filled in shape using red. A 9-pensize Chocolate4 65° line from (18, 69) to (77, 196). A 9-pensize Chocolate4 105° line from (77, 196) to (62, 254). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (53, 266) with a 15-unit major axis at 125° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (63, 269) with a 15-unit major axis at 85° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 65° line from (77, 196) to (103, 250). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (104, 265) with a 15-unit major axis at 85° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (113, 261) with a 15-unit major axis at 45° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 25° line from (77, 196) to (132, 221). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (142, 232) with a 15-unit major axis at 45° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (147, 223) with a 15-unit major axis at 5° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize red ellipse centered at (81, 203) with a 8.1-unit major axis at 65° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (86, 195) with a 8.1-unit major axis at 173° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (79, 188) with a 8.1-unit major axis at 101° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (70, 192) with a 8.1-unit major axis at 29° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (72, 202) with a 8.1-unit major axis at 137° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red circle centered at (77, 196) with radius 4.1 Filled in shape using red. A 9-pensize Chocolate4 105° line from (18, 69) to (-18, 204). A 9-pensize Chocolate4 145° line from (-18, 204) to (-67, 239). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-82, 243) with a 15-unit major axis at 165° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-76, 251) with a 15-unit major axis at 125° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 105° line from (-18, 204) to (-33, 262). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-42, 275) with a 15-unit major axis at 125° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-32, 277) with a 15-unit major axis at 85° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 65° line from (-18, 204) to (7, 259). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (9, 274) with a 15-unit major axis at 85° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (18, 269) with a 15-unit major axis at 45° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize red ellipse centered at (-20, 212) with a 8.1-unit major axis at 105° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-11, 209) with a 8.1-unit major axis at 33° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-12, 199) with a 8.1-unit major axis at 141° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-21, 197) with a 8.1-unit major axis at 69° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-26, 205) with a 8.1-unit major axis at 177° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red circle centered at (-18, 204) with radius 4.1 Filled in shape using red. A 9-pensize Chocolate4 145° line from (18, 69) to (-96, 150). A 9-pensize Chocolate4 5° line from (-96, 150) to (-156, 144). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-170, 138) with a 15-unit major axis at 25° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-171, 148) with a 15-unit major axis at 165° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 145° line from (-96, 150) to (-146, 184). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-160, 188) with a 15-unit major axis at 165° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-154, 196) with a 15-unit major axis at 125° and a 10-unit minor axis Filled in shape using Chartreuse2. A 9-pensize Chocolate4 105° line from (-96, 150) to (-112, 207). Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-121, 220) with a 15-unit major axis at 125° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize Chartreuse2 ellipse centered at (-111, 222) with a 15-unit major axis at 85° and a 10-unit minor axis Filled in shape using Chartreuse2. Start of filled shape. A 2-pensize red ellipse centered at (-103, 154) with a 8.1-unit major axis at 145° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-94, 157) with a 8.1-unit major axis at 73° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-88, 150) with a 8.1-unit major axis at 1° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-94, 142) with a 8.1-unit major axis at 109° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red ellipse centered at (-103, 145) with a 8.1-unit major axis at 37° and a 5.4-unit minor axis Filled in shape using red. Start of filled shape. A 2-pensize red circle centered at (-96, 150) with radius 4.1 Filled in shape using red.Out[]:Image372
Main
This example shows how the main function doesn't accept any parameters. This is required so that we can test your code without knowing what parameters you chose to put in your tree function. The turtle does NOT have to end up back where it started, and you can (like in this example) call tree more than once if you like.
In []:Prints# Draw the tree(s) main() # Show the turtle's position (it's NOT back at the start) color('black') stamp()
A 15-pensize Sienna vertical line from (0, -120) to (0, 60). A 7.5-pensize Sienna 30° line from (0, 60) to (104, 120). A 7.5-pensize Sienna 70° line from (104, 120) to (124, 176). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (124, 191) with a 15-unit vertical major axis and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (134, 188) with a 15-unit major axis at 50° and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 30° line from (104, 120) to (156, 150). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (166, 161) with a 15-unit major axis at 50° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (171, 153) with a 15-unit major axis at 10° and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 170° line from (104, 120) to (163, 110). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (178, 112) with a 15-unit major axis at 10° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (176, 102) with a 15-unit major axis at 150° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize pink ellipse centered at (111, 124) with a 8.1-unit major axis at 30° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (110, 115) with a 8.1-unit major axis at 138° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (101, 113) with a 8.1-unit major axis at 66° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (96, 121) with a 8.1-unit major axis at 174° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (102, 128) with a 8.1-unit major axis at 102° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink circle centered at (104, 120) with radius 4.1 Filled in shape using pink. A 7.5-pensize Sienna 70° line from (0, 60) to (41, 173). A 7.5-pensize Sienna 110° line from (41, 173) to (21, 229). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (11, 241) with a 15-unit major axis at 130° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (21, 244) with a 15-unit vertical major axis and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 70° line from (41, 173) to (62, 229). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (62, 244) with a 15-unit vertical major axis and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (71, 241) with a 15-unit major axis at 50° and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 30° line from (41, 173) to (93, 203). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (103, 214) with a 15-unit major axis at 50° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (108, 205) with a 15-unit major axis at 10° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize pink ellipse centered at (44, 180) with a 8.1-unit major axis at 70° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (49, 172) with a 8.1-unit major axis at 178° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (43, 165) with a 8.1-unit major axis at 106° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (34, 168) with a 8.1-unit major axis at 34° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (35, 178) with a 8.1-unit major axis at 142° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink circle centered at (41, 173) with radius 4.1 Filled in shape using pink. A 7.5-pensize Sienna 110° line from (0, 60) to (-41, 173). A 7.5-pensize Sienna 150° line from (-41, 173) to (-93, 203). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-108, 205) with a 15-unit major axis at 170° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-103, 214) with a 15-unit major axis at 130° and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 110° line from (-41, 173) to (-62, 229). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-71, 241) with a 15-unit major axis at 130° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-62, 244) with a 15-unit vertical major axis and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 70° line from (-41, 173) to (-21, 229). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-21, 244) with a 15-unit vertical major axis and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-11, 241) with a 15-unit major axis at 50° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize pink ellipse centered at (-44, 180) with a 8.1-unit major axis at 110° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-35, 178) with a 8.1-unit major axis at 38° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-34, 168) with a 8.1-unit major axis at 146° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-43, 165) with a 8.1-unit major axis at 74° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-49, 172) with a 8.1-unit major axis at 2° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink circle centered at (-41, 173) with radius 4.1 Filled in shape using pink. A 7.5-pensize Sienna 150° line from (0, 60) to (-104, 120). A 7.5-pensize Sienna 10° line from (-104, 120) to (-163, 110). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-176, 102) with a 15-unit major axis at 30° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-178, 112) with a 15-unit major axis at 170° and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 150° line from (-104, 120) to (-156, 150). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-171, 153) with a 15-unit major axis at 170° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-166, 161) with a 15-unit major axis at 130° and a 10-unit minor axis Filled in shape using SpringGreen1. A 7.5-pensize Sienna 110° line from (-104, 120) to (-124, 176). Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-134, 188) with a 15-unit major axis at 130° and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize SpringGreen1 ellipse centered at (-124, 191) with a 15-unit vertical major axis and a 10-unit minor axis Filled in shape using SpringGreen1. Start of filled shape. A 2-pensize pink ellipse centered at (-111, 124) with a 8.1-unit major axis at 150° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-102, 128) with a 8.1-unit major axis at 78° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-96, 121) with a 8.1-unit major axis at 6° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-101, 113) with a 8.1-unit major axis at 114° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink ellipse centered at (-110, 115) with a 8.1-unit major axis at 42° and a 5.4-unit minor axis Filled in shape using pink. Start of filled shape. A 2-pensize pink circle centered at (-104, 120) with radius 4.1 Filled in shape using pink.Out[]:Image483
=
or by defining a parameter for a function) you must also later use that variable as part of another expression. If you need to create a variable that you won't use, it must have the name _
, but you should only do this if absolutely necessary.main
must not crash.
main
function without any arguments. It should be able to draw something andfinish without crashing.main
tree parts must each put the turtle back where they found it.
main
function without any arguments. We will measure where the turtle moves, including where it is at the start and end of each inner function call. We will check to make sure that the position at the start of the tree and each branch, twig, and leaf is the same as the position after that function call is done, including x, y position and heading.leaf
def
to define leaf
leaf
must call one of the required turtle
drawing functions.
leaf
, we will inspect the code for leaf
and check to make sure that it includes at least one call to any of the following functions:circle
drawCircle
drawEllipse
drawDot
drawSquare
drawRectangle
drawPolygon
drawText
fd
forward
twig
def
to define twig
twig
must call one of the required turtle
drawing functions.
twig
, we will inspect the code for twig
and check to make sure that it includes at least one call to any of the following functions:circle
drawCircle
drawEllipse
drawDot
drawSquare
drawRectangle
drawPolygon
drawText
fd
forward
leaf
twig
, call leaf
in at least 2 places.branch
def
to define branch
branch
must call one of the required turtle
drawing functions.
branch
, we will inspect the code for branch
and check to make sure that it includes at least one call to any of the following functions:circle
drawCircle
drawEllipse
drawDot
drawSquare
drawRectangle
drawPolygon
drawText
fd
forward
branch
must call one of the required turtle
turning functions.
branch
, we will inspect the code for branch
and check to make sure that it includes at least one call to any of the following functions:circle
drawCircle
drawEllipse
drawDot
drawSquare
drawRectangle
drawPolygon
drawText
fd
forward
twig
branch
, call twig
in at least 2 places.tree
def
to define tree
tree
must call one of the required turtle
drawing functions.
tree
, we will inspect the code for tree
and check to make sure that it includes at least one call to any of the following functions:circle
drawCircle
drawEllipse
drawDot
drawSquare
drawRectangle
drawPolygon
drawText
fd
forward
tree
must call one of the required turtle
turning functions.
tree
, we will inspect the code for tree
and check to make sure that it includes at least one call to any of the following functions:circle
drawCircle
drawEllipse
drawDot
drawSquare
drawRectangle
drawPolygon
drawText
fd
forward
branch
tree
, call branch
in at least 2 places.main
def
to define main
tree
main
, call tree
in at least one place.