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

Conditionals: If, Then, Else

Directions

In these steps, when a condition is true, the program does the then part, and when it is false, the program does the else part if there is one. Every condition is checked using the value that the variable has at that exact moment.

Question 1 of 8Answered

A video game decides how many bonus points to give at the end of each level by following these steps.

  1. Set score to 12.
  2. If score is 10 or more, then add 5 to score. Else, add 1 to score.

What is the value of score after step 2 has finished?

Enter a number.

Question 2 of 8Answered

A library app uses these steps to decide whether a borrowed book is overdue. The variable days counts how many days the book has been checked out.

  1. Set days to 14.
  2. If days is more than 14, then set fine to 1. Else, set fine to 0.

What is the value of fine after step 2 has finished?

Enter a number.

Question 3 of 8Answered

A digital speed sign near an elementary school measures each passing car and decides which message to display to the driver by following these steps.

  1. Set speed to 35.
  2. If speed is 30 or less, then show the message Thanks. Else, show the message Slow Down.

Which message does the sign display?

Choose one answer.

Question 4 of 8Answered

A vocabulary quiz app awards each player stars at the end of a round by following these steps.

  1. Set points to 85.
  2. If points is 90 or more, then set stars to 3. Else, if points is 70 or more, then set stars to 2. Else, set stars to 1.

What is the value of stars after step 2 has finished?

Enter a number.

Question 5 of 8Answered

A sorting robot in a factory examines these numbers one at a time, in this order: 3, 8, 5, 10, 2. Step 2 runs once for each of the 5 numbers.

  1. Set count to 0.
  2. For each number: if the number is more than 4, then add 1 to count.

What is the value of count after step 2 has checked every number?

Enter a number.

Question 6 of 8Answered

Dana's teacher wants a program that displays Pass for every score of 60 and above, and Try Again for every score below 60. Which step does exactly that?

Choose one answer.

Question 7 of 8Answered

A packing program at an apple orchard uses these steps to decide how to fill paper bags with freshly picked apples.

  1. Set apples to 9.
  2. Set bags to 0.
  3. If apples is more than 5, then do both of these: add 2 to bags, then subtract 5 from apples. Else, add 1 to bags.

What is the value of apples after step 3 has finished?

Enter a number.

Question 8 of 8Answered

A greenhouse heater program has three if steps in a row, and none of them has an else part. Each one checks temperature again, using the value temperature has when that step starts.

  1. Set temperature to 6.
  2. If temperature is less than 10, then add 5 to temperature.
  3. If temperature is less than 10, then add 5 to temperature.
  4. If temperature is more than 12, then subtract 3 from temperature.

What is the value of temperature after step 4 has finished?

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