Arithmetic and Assignment
Scenario: The cashier must calculate a subtotal and apply a discount.
New words, in plain English
- Operator - a symbol that performs an operation
- Operand - a value an operator works on
- Precedence - the order in which operations happen
Python supports + - / // % *. Parentheses make intent explicit. Short assignment forms such as count += 1 update an existing name.
Analogy: A Python program is like a clear set of instructions for a careful helper: names label things, indentation groups steps, and errors explain where the helper became confused.
A small, real example
subtotal = 6.50 * 3
discount = subtotal * 0.10
total = subtotal - discount
print(round(total, 2))
Tip: Money needs decimal-aware design in serious systems; floats are fine for learning but can contain tiny rounding errors.
Goal: Practice this idea in the py-variables-types challenge at/labs/python. Fix the broken program, run it yourself, then usecheckto prove the real end state.