6
Page 3: Self-Check: Tree Inputs
Unit 7, Lab 1, Page 3
On this page, you will consider how changes to the input arguments for tree impact the resulting drawing.
Each of these questions refer to this version of the tree block and this script that calls it. Notice the circled blank level input slot in the tree block in the calling script. Also, inside the tree script, the turning angles and size scaling factors have been changed so that the left and right branches are the same, making the pictures of trees easier to understand.

If this picture is drawn, what number must be in the level input slot of the treeprocedure?How many different sizes of line segment are in the picture?
1
How many different sizes of line segment are in the picture?
5
Nice! There are indeed five different levels present in the tree.
4
How many different sizes of line segment are in the picture?
What would happen if you changed the input size to be -100? (Don’t use Snap!. The point is to think about it.)
The program will never stop running and a lot of different branches will be drawn.
The program will stop. Try walking through the function step-by-step using the given inputs.
It will never stop running and only a single branch will be drawn.
The program will stop. Try walking through the function step-by-step using the given inputs.
It will work just as if the size were positive 100.
Not quite. What happens when we plug in a negative value to the
moveblock?The image will be flipped upside down but will otherwise look the same.
Nice! Inputting negative values to the move block will make the sprite move backwards.
Nothing will be drawn.
Something will be drawn. Try walking through the function step-by-step using the given inputs.
What would happen if you changed the input level to be -4? (Don’t use Snap!. The point is to think about it.)
The program will never stop running, but it will draw a tree-looking tree with more and more smaller and smaller branches.
It’s true that the program will never stop running. Try walking through the code step-by-step to see exactly what it draws.
It will never stop running, and the picture will be a leftward spiral with the sprite spinning around in midair.
Correct! The function will never hit the
level = 1case, and will only ever make the left-branch call to itself.It will work just as if the level were positive 4.
Will the recursion ever reach level 1?
The image will be flipped upside down but will otherwise look the same.
Does the level input affect the
moveblocks?Nothing will be drawn.
Something will be drawn.
How would you change the definition of treeso that it doesn’t get stuck in an infinite loop even with a negative input for level?