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

Debugging: Find the Step That Is Wrong

Directions

Each program below has a goal, which lists everything the program should show on the screen, in order. "Show" puts a value or a message on the screen. Exactly one step in each program is wrong, so trace the steps one at a time, keep a list of everything the program shows, and compare your list with the goal.

Question 1 of 8Answered

Soren is writing a program for a neighborhood bakery that keeps track of how many cookies are sitting on the front display tray during the morning.

Goal: the program should show 4, then 12, then 7, and finally the message Tray updated.

  1. Set cookies to 4, then show cookies.
  2. Add 3 to cookies, then show cookies.
  3. Subtract 5 from cookies, then show cookies.
  4. Show the message Tray updated.

Which of the four steps causes the program's first wrong result?

Choose one answer.

Question 2 of 8Answered

Thandi built a science program that models a patch of moss growing on a rock, where the moss doubles in size every single week. The program should display the size at the very beginning and again after each of three weeks.

Goal: the program should show 2, then 4, then 8, and finally 16.

  1. Set moss to 1, then show moss.
  2. Double moss, then show moss.
  3. Double moss, then show moss.
  4. Double moss, then show moss.

Which step number is responsible for the wrong result? Enter that step number.

Enter a number.

Question 3 of 8Answered

Elodie is making a word game for her younger cousins that builds the word sunflower, one piece at a time. In her program, "followed by" joins two pieces of text into one, keeping them in exactly the order they are written.

Goal: the program should show sun, then sunflow, then sunflower, and finally the message Word complete.

  1. Set word to "sun", then show word.
  2. Set word to "flow" followed by word, then show word.
  3. Set word to word followed by "er", then show word.
  4. Show the message Word complete.

Which step needs to be fixed so that the program reaches its goal?

Choose one answer.

Question 4 of 8Answered

Bastian's program keeps track of the apples for sale at a farm stand, along with the paper bags the farmers use to pack apples for their customers.

Goal: the program should show 10, then 0, then 5, and finally 1.

  1. Set apples to 10, then show apples.
  2. Set bags to 0, then show bags.
  3. Subtract 5 from apples, then show apples.
  4. Add 1 to apples, then show bags.

In which of these four steps is the bug that causes the wrong result?

Choose one answer.

Question 5 of 8Answered

Ines wrote a program that counts the laps she swims during practice, adding 3 laps for each set she finishes. During today's practice, she swims exactly three sets.

Goal: the program should show 3, then 6, then 9, and finally the message Done.

  1. Set laps to 0.
  2. Repeat 4 times: add 3 to laps, then show laps.
  3. Show the message Done.

Enter the number of the step that is wrong.

Enter a number.

Question 6 of 8Answered

Viktor's video game program displays a player's points at the beginning of the game and again after each of three bonus rounds.

Goal: the program should show 5, then 8, then 11, then 14, and finally the message Finished.

  1. Set points to 5.
  2. Show points.
  3. Repeat 3 times: add 2 to points, then show points.
  4. Show the message Finished.

Which step contains the mistake?

Choose one answer.

Question 7 of 8Answered

Marisol's quiz program should display Pass for any score of 60 or more and Try Again for any lower score. To test the program, she gives it a score of exactly 60.

Goal: the program should show 60, then the message Pass, and finally the message Quiz checked.

  1. Set score to 60.
  2. Show score.
  3. If score is more than 60, then show the message Pass. Else, show the message Try Again.
  4. Show the message Quiz checked.

Which step causes the program to miss its goal?

Choose one answer.

Question 8 of 8Answered

Ronan's reading app keeps track of how many pages his library book has, how many pages he has finished, and how many pages are still remaining.

Goal: the program should show 120, then 45, then 75, and finally the message Keep reading.

  1. Set pages to 120, then show pages.
  2. Set finished to 45, then show finished.
  3. Set remaining to finished − pages, then show remaining.
  4. Show the message Keep reading.

What is the number of the step that causes the wrong result?

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