← Back to course
Code Crew G3 / Week 03 / Tuesday
2/6
Week 03 Β· Conditionals

Tuesday

// If this, then that

Tuesday: Choose-Your-Adventure

Rocket finds a snack on the kitchen table. "Can I eat it?" he asks. He reaches for it fast.

Raven stops him gently. "What do you notice on the wrapper?" she asks.

Nova floats down. "Read the if first," she says. "Then pick your path."

Let's follow each decision. Then we'll take turns being the computer.

Read the decision. Circle the path you would take. Then answer the next conditional based on your choice.

You walk into the kitchen and see a snack on the table.
IF the snack has your name on it
β†’ eat it!
ELSE
β†’ ask a grown-up first.
Outside, the sky looks dark.
IF the sky is gray AND cloudy
β†’ grab a coat.
ELSE IF the sky is clear
β†’ wear a t-shirt.
ELSE
β†’ check the weather app.
β—‡ PARTNER MOVE
With a partner, take turns being the COMPUTER.
One person reads the IF, the other answers what to do.

ELSE IF: More Than Two Paths

Sometimes there are more than two choices. ELSE IF adds another question.

Nova checks the questions from top to bottom. She stops at the first true one.

IF the light is red:
    stop
ELSE IF the light is yellow:
    slow down
ELSE:
    go
FOLLOW THE LIGHT
  • Read the question.
  • Tap your answer.
The light is yellow. What do you do?
The light is red. What do you do?
The light is green. What do you do?
How many questions does this code ask at most?
StatementTrue or false?
Nova checks the questions from top to bottom.?
ELSE IF asks a new question.?
ELSE asks a question too.?
Nova runs every true path at the same time.?
WHY THIS EXERCISEELSE IF lets one rule handle many cases, in order.
Rule: IF it is hot, THEN swim. ELSE IF it is cool, THEN hike. ELSE read. It is cool. What do you do?
WHY THIS EXERCISENova stops at the first question that is true.
Try it
Walk from room to room at home.
At each doorway, say an IF rule out loud.
Example: IF the light is on, THEN turn left. ELSE turn right.

Quick Check

Use the sky decision above. The sky is clear. What do you wear? ____
Same decision. The sky is gray and cloudy. What do you grab? ____
← Monday