Make Python Calculate
A useful program stores a result, then explains what that number means.
Discover
- A variable can remember a calculated value.
- Use = to assign a value.
- Good variable names describe the information.
Try, explain and change
Try: A classroom has 24 red counters and 18 blue counters. Store their sum in a variable named total and print “Total: 42”.
Change: Change the blue counters to 20 and predict the total before running.
Try the challenge
A classroom has 24 red counters and 18 blue counters. Store their sum in a variable named total and print “Total: 42”.
Total: 42Match the lines and order. Your code must use the lesson concept.
The runner supports this pathway’s controlled Python concepts while blocking packages, files, networks and system commands.
Your output will appear here.
Find the bug
total = 24 + 18
print("Total:" total)Show debugging clue
Add a comma between the message and the variable.
What does = do here?
Compares two games
Not this time. Review Discover and try again.
Stores a value in a variable
Correct — well reasoned.
Prints a value
Not this time. Review Discover and try again.
Create and reflect
Create: Build a small shopping-total calculator with two item prices.
Reflect: Why is total a clearer name than x?
Add 3 green counters and update the total. Explain which value changed.
Edit and run your code again to explore this variation. It does not change lesson completion.