Ms. Whitby's Classroom logo Ms. Whitby's Classroom

Values, Variables & Expressions — Lesson 2: Calculate with numbers

New skill: Integer arithmetic
Previously learned: Unit 01 — output, execution, and debugging

Why this matters

Unlike strings, integers support calculations. Python evaluates arithmetic expressions before producing output.

Study this example

minutes = 30
sessions = 4
print(minutes * sessions)
print(15 // 4)
print(15 % 4)

* multiplies. // gives a whole-number quotient; % gives a remainder. The result of 30 × 4 is 120. You can keep numbers in variables and compute when needed.

Before moving on, trace each line of the example by hand. Predict the result before running it in the browser.

Check your understanding

Predict 7 * 6, 17 // 5, and 17 % 5 before running.

Common mistake

Quoted numbers such as '12' are strings, not integers.

Practice: Calculate with numbers

A robotics club runs 3 sessions lasting 45 minutes each. Use variables named sessions and minutes to calculate and print the total number of minutes: 135.

Expected console output

135

Starter file: main.py

Use Run to experiment and Check to compare against published examples. A passing public example does not automatically establish mastery.

Hint 1 — Identify the key concept Identify the operation that combines repeated equal durations.
Hint 2 — Find an approach Use the two existing variables rather than printing 135 directly.
Hint 3 — Check your answer `print()` should display the numeric result.

Reflection

Write a short explanation of why your code works. What input or change would make it behave differently?