Self-Check: Tree Inputs

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.

MARY: Images and alt-text need to be redone. --MF, 6/19/20
tree level: (level #) size: (size #){
            if (level=1) {
                move (size) steps
                move(-1*size) steps}
            else{
                move (size) steps
                turn counterclockwise (15) degrees
                tree level: (level-1) size: (size*0.75)
                turn clockwise(15) degrees
                turn clockwise(15) degrees
                tree level: (level-1) size: (size*0.75)
                turn counterclockwise (15)
                move(-1*size) steps
            }
            } go to x:(0) y:(-140)
                clear
                point in direction(0)
                pen down
                tree level: ( ) size: (100)
                (Note: the 'level' input to the 'tree' block is circled in red.)

  1. A tree with trunk and four levels of branches If this picture is drawn, what number must be in the level input slot of the tree procedure?
    6
    1
    5
    4
  2. 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.
    It will never stop running and only a single branch will be drawn.
    It will work just as if the size were positive 100.
    The image will be flipped upside down but will otherwise look the same.
    Nothing will be drawn.
  3. 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 will never stop running, and the picture will be a leftward spiral with the sprite spinning around in midair.
    It will work just as if the level were positive 4.
    The image will be flipped upside down but will otherwise look the same.
    Nothing will be drawn.
  4. Talk with Your PartnerHow would you change the definition of tree so that it doesn't get stuck in an infinite loop even with a negative input for level?