← Back to course
Code Crew G6+ / Week 03 / Crew Quest
6/6
Week 03 Β· Decisions

Crew Quest

Crew Quest: Decision map
// if, elif, else and the logic words
⏱ about 30 min

Saturday: Crew Quest: Decision map

The crew is planning the weekend at Mission Control. Rocket wants a program that picks an activity based on the weather and how much time there is.

"Before I write any code, I want a map," he says, which surprises everyone, including himself.

Raven grins and hands him a marker. "What do you notice when you draw it first?" she asks. "You can see every path before you build it."

Nova projects a diamond shape for each question and a box for each answer. "I found a pattern," she says. "Each diamond is an if. Each path out of it is a block."

Rocket draws the first diamond on the whiteboard and writes: is it raining?

  1. Comparisons give True or False: ==, !=, <, >, <=, >=.
  2. if runs its block when the condition is True. else runs when it is False.
  3. elif checks the next condition only when the ones above were False. Order matters.
  4. and needs both sides True, or needs one, not flips the answer.
  5. .strip().lower() cleans up typed answers before you compare them.
Is it raining?
↓ DECISION ↓
Yes: build a model indoors
↓
No: is there more than an hour?
↓ DECISION ↓
Yes: launch kites in the park
↓
No: sketch the stars from the window
β—‡ DRAW A DECISION MAP
With a grown-up, pick a real everyday decision, like what to do after school.
Draw it as a map: a diamond for each question and a box for each answer.
Then write it as Python with if, elif and else, on paper or in IDLE.
Test it together: pick answers and follow the path with your finger.
WEEK 3 CHECK
  • Read the question.
  • Tap your answer.
x = 15. Which block runs? if x > 20 runs A, elif x > 10 runs B, else runs C.
What does 3 > 1 and 2 > 5 give?
MORE REVIEW: WEEK 3
  • Read the question.
  • Tap your answer.
fuel = 50. Which condition is True?
What does not (3 > 5) give?
A chain has if, two elifs and else. How many blocks can run at once?

Great work. Next week your programs start repeating themselves, on purpose.

← Friday