Practice Your answers and score aren't saved. Back to the activity

Loops: Repeat the Steps

Directions

Every question includes a loop, which is a step that repeats. Before you trace, check exactly how many times each loop runs or what makes it stop, then follow the steps one at a time.

Question 1 of 8Answered

At a school carnival, a ring-toss game uses these steps to work out how many prize tickets a player earns.

  1. Set tickets to 7.
  2. Repeat 5 times: add 6 to tickets.
  3. Subtract 9 from tickets.

What is the value of tickets after the game finishes step 3?

Enter a number.

Question 2 of 8Answered

Arjun wrote a program in which the same step, adding 3 to score, appears five times in a row.

  1. Add 3 to score.
  2. Add 3 to score.
  3. Add 3 to score.
  4. Add 3 to score.
  5. Add 3 to score.

Which single loop step does exactly the same thing as these five steps?

Choose one answer.

Question 3 of 8Answered

A science game uses these steps as a simple model of how a small group of cells grows during an experiment.

  1. Set cells to 3.
  2. Repeat 4 times: double cells.
  3. Subtract 8 from cells.

What is the value of cells after the game finishes step 3?

Enter a number.

Question 4 of 8Answered

Talia designed a pattern program for her art class, and it follows these steps.

  1. Set size to 2.
  2. Repeat 4 times, doing both actions each time: double size, then subtract 1 from size.

What is the value of size after the loop in step 2 is finished?

Enter a number.

Question 5 of 8Answered

A robot dancer performs a short routine by following these steps. Before the routine begins, the robot has not done any claps or spins.

  1. Repeat these moves 3 times: clap 4 times in a row, then spin once.

How many claps and spins does the robot do in all?

Enter a number.

Question 6 of 8Answered

Zoe is programming a holiday light display. She wants these steps to end with lights equal to 20, but they end with 24 instead.

  1. Set lights to 4.
  2. Repeat 5 times: add 4 to lights.

Which change makes the steps end with 20?

Choose one answer.

Question 7 of 8Answered

These steps use two variables, total and count, that change as the loop runs. In these steps, "Add count to total" changes only total.

  1. Set total to 0.
  2. Set count to 1.
  3. Repeat 6 times, doing both actions each time: add count to total, then add 1 to count.

What is the value of total after the loop in step 3 is finished?

Enter a number.

Question 8 of 8Answered

A rocket game fills a fuel tank with these steps. Step 2 checks fuel before every round, so the loop stops as soon as fuel is 20 or more.

  1. Set fuel to 3.
  2. Repeat until fuel is 20 or more: add 5 to fuel.

How many times does step 2 add 5 to fuel?

Enter a number.

All done? Finish.

8 questions are not answered yet. Pick a number to go back to it.

Finish to see your score and every answer.

0 of 8 answered