← Back to course
Code Crew G5 / Week 01 / Crew Quest
6/6
Week 01 Β· Crew check

Crew Quest

Crew Quest: Catalog cards
// The tools you already have
⏱ about 15 min

Crew Quest: Catalog cards

The whole crew gathers in the observation deck. Rocket spreads paper cards across the table.

"Let us make the star catalog with our hands," he says. "Each card is one star."

Raven lines the cards up in a row. "What do you notice if we number them the Python way?"

"The first card gets a 0," Rocket says. "So the last card is one less than the count."

Nova sparkles. "Here is a hint. Say the index out loud each time you touch a card."

  1. A list keeps values in order. Spots start at 0. len() counts the items.
  2. A for loop visits every item. A running total adds as it goes.
  3. if, elif and else pick exactly one choice.
  4. A dictionary pairs keys with values.
  5. A function uses return to hand a value back.
β—‡ CATALOG CARDS
Write five made-up star names on five paper cards.
Lay them in a row. Write 0, 1, 2, 3, 4 above them.
Your partner calls out an index, like "stars[3]".
You touch the right card and read the name.
Swap roles. Then try a negative index, like stars[-1].
For a grown-up
No screen is needed today. If your child picks the wrong card, ask them to count from 0 out loud.
RECAP QUESTION
  • Read the question.
  • Tap your answer.
A list has 6 items. What is the index of the last item?
Bonus recap statementTrue or false?
["a", "b", "c"] has a last index of 2.?
A for loop visits each item once.?
elif runs when the if before it is True.?
A dictionary finds values by key.?
WHY THIS EXERCISEThese four facts cover the whole week.
What does len([4, 4, 4, 4]) give?
What does {"x": 9}["x"] give?
double(n) returns n * 2. What is double(double(2))?

Quest complete! Next week we find out what happens when one function calls another.

← Friday