# First Practice Quiz - repeat, if, def¶

• CS20-CP1 Apply various problem-solving strategies to solve programming problems throughout Computer Science 20.
• CS20-FP2 Investigate how control structures affect program flow.

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:

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:

Option 2:

Option 3:

Option 4:

• 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:

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:

Option 2:

Option 3:

Option 4:

• 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¶

Assume the starting world looks like this:

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-quiz3: Assume the starting world looks like this:

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)