First Practice Quiz - repeat, if, def

To confirm that you understand the major concepts you’ve seen with Reeborg, try to answer the following questions without opening the Reeborg environment.

Question 1 - Repeat Loops

    reeborg-practice-quiz1: Consider the following world, in which Reeborg is holding 4 daisies:

    ../_images/quiz-starting-world.png

    Assume the following code is executed:

    repeat 4:
        put()
    move()
    

    Which of the following images shows what the world would look like after the code is finished running?

    Option 1:

    ../_images/quiz-optiona.png

    Option 2:

    ../_images/quiz-optionb.png

    Option 3:

    ../_images/quiz-optionc.png

    Option 4:

    ../_images/quiz-optiond.png
  • Option 1
  • Notice that move() is not in the repeat loop. Try again!
  • Option 2
  • Careful! There should be more than one daisy down...
  • Option 3
  • Great!
  • Option 4
  • Careful! move() will only happen once. Try again!

Question 2 - Repeat Loops

    reeborg-practice-quiz2: Note: This question is very similar to the last one, but there is a slight change. Read carefully! Consider the following world, in which Reeborg is holding 4 daisies:

    ../_images/quiz-starting-world.png

    Assume the following code is executed:

    repeat 4:
        put()
        move()
    

    Which of the following images shows what the world would look like after the code is finished running?

    Option 1:

    ../_images/quiz-optiona.png

    Option 2:

    ../_images/quiz-optionb.png

    Option 3:

    ../_images/quiz-optionc.png

    Option 4:

    ../_images/quiz-optiond.png
  • Option 1
  • Great!
  • Option 2
  • Careful! There should be more than one daisy down...
  • Option 3
  • Notice that move() is inside repeat. Try again!
  • Option 4
  • Careful! Both commands inside repeat will happen, in order. Try again!

Question 3 - Repeat and If

reeborg-practice-quiz3: Assume the starting world looks like this:

../_images/quiz-starting-world2.png

The following code is then executed:

repeat 10:
    move()
    if object_here():
        take()

How many dandelions has Reeborg picked up when the code has finished?

Question 4 - Repeat and Def

    reeborg-practice-quiz4: Assume the starting world looks like this:

    ../_images/quiz-starting-world3.png

    The following code is then executed:

    def turn_right():
        repeat 3:
            turn_left()
    
    def turn_around():
        repeat 2:
            turn_left()
    
    def move_and_pick():
        move()
        take()
    
    def weeding_time():
        repeat 2:
            move_and_pick()
    
    repeat 4:
        move()
    turn_left()
    move()
    turn_left()
    
    weeding_time()
    move()
    turn_right()
    move()
    turn_right()
    
    weeding_time()
    move()
    

    How many dandelions has Reeborg picked up when the code has finished?

  • 0
  • Try again!
  • 4
  • Great!
  • 7
  • Try again!
  • An error will occur
  • Try again!
Next Section - Step 10: Jumping Hurdles (repeat and functions)