1.3 Operators

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

1.3 Operators

Operators are symbols that do something with values: maths, comparison, or logic.

Maths operators

Symbol Meaning Example
+ Add 5 + 3 → 8
- Subtract 5 - 3 → 2
* Multiply 5 * 3 → 15
/ Divide 6 / 3 → 2.0
// Divide (whole number) 7 // 2 → 3
% Remainder 7 % 2 → 1

You can use variables too: score * 2, health - 1.

Comparison operators

These compare two values and give True or False:

Symbol Meaning Example
== Equal to 5 == 5 → True
!= Not equal to 5 != 3 → True
< Less than 3 < 5 → True
> Greater than 10 > 7 → True
<= Less or equal 4 <= 4 → True
>= Greater or equal 3 >= 3 → True

Example:

score = 10
print(score > 5)   # True
print(score == 10) # True

Logical operators

Mini project: Simple calculator

Ask the user for two numbers (use int(input(...))). Then print:


Next: 2.1 Conditionals — making decisions with if and else.