──────────────────────────────────────

3. Broadcast from Base Camp · Pack for the Expedition

Calculate a total and label it using an f-string.

Lesson files · lessons/first-programs/numbers-and-f-strings

Before you start
- Store whole numbers in variables.
- Print the value stored under a name.

By the end
- Use multiplication to calculate a supply total.
- Use an f-string to put that total in a label.
- Test that the label updates when the group size changes.

Where you can use it
Work out how many pencils a class needs. Multiply the number of desks by the pencils per desk and show the total with a label.

Python uses * for multiplication. Store the number of people and the packs for each person under two names. Then multiply them to get the total.

An f-string starts with f before the opening quote. At the spot marked {total}, Python inserts the current value of total. Try changing people to 5 and predict the new label before running it.

Predict
If people becomes 0, what total should appear?
- 0
- 2

Worked example (example.py)

people = 4
packs_each = 2
total = people * packs_each
print(f"Supply packs: {total}")


Example result
Supply packs: 8

Pack three supply packs per person for a group of six. Print Supply packs: 18 using the calculation.

Starter program (starter.py)

people = 4
packs_each = 2
total = people * packs_each
print(f"Supply packs: {total}")


Hint
Change people and packs_each. Keep the expression for total so the label stays correct if you change the numbers again.

Case 1. Try the sample
Input
(No input.)
Expected output
Supply packs: 18

Stretch
Use + to add two spare packs to the total. Predict and explain the new output for six people and for zero people.

Reflect
Which numbers can you change without touching the print call?

Check your prediction
0 Zero people times any number of packs per person gives zero.
