DPython for KidsModule 2 · Lesson 2.3
LESSON 2.3 · 35 MINUTES

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.

SAFE PYTHON RUNNER

Try the challenge

No files · no network · safe lesson commands only

A classroom has 24 red counters and 18 blue counters. Store their sum in a variable named total and print “Total: 42”.

Target output
Total: 42
Match 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.

Output
Your output will appear here.
DEBUG DETECTIVE

Find the bug

total = 24 + 18
print("Total:" total)
Show debugging clue

Add a comma between the message and the variable.

QUICK CHECK

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?

Stretch practice · self check

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.