← Back to course
Code Crew G4 / Week 01 / Crew Quest
6/6
Week 01 Β· Values and print

Crew Quest

Crew Quest: Cup Variables
// Real Python, one line at a time
⏱ about 15 min

Crew Quest: Cup Variables

Tonight the station dims its screens to save power. "No screens?" Rocket asks. "How do we code?"

Raven holds up three paper cups. "What do you notice? Each one could be a box with a name." She writes fuel on one cup and crates on another.

Nova smiles with her blue eyes. "A variable is just a named place to keep a value," she says. "Paper and cups work too." Rocket grabs a pencil. "Let's build it!"

  1. print shows a value on the screen.
  2. A string is text inside quote marks.
  3. A variable is a name that stores a value. The = sign stores it.
  4. Python works out the right side of = first, then stores the answer.
  5. + adds numbers and joins strings. Commas in print put a space between values.
β—‡ CUP VARIABLES
You need three paper cups, scrap paper and a pencil.
Write a variable name on each cup, like fuel, crates and pods.
Your partner reads a line, like fuel = 10.
Write the value on a scrap and drop it in the cup.
When the value changes, take the old scrap out first. A box holds one value.
When your partner says print, read the value out loud.

Here is a program you can act out with your cups.

score = 4
score = score + 6
print(score)
What number does the cup program show?
WHY THIS EXERCISEActing out a variable helps you remember that the old value is replaced.
BONUS RECAP
  • Read the question.
  • Tap your answer.
What does print("Go" + "Go") show?
x = 2 runs. Then x = x * 5 runs. What is in x?
Which line puts a space between Fuel: and 9?

You finished week one! Next week, the cargo bay needs a list.

← Friday