🐍 Python 2026 › Lesson 5: Operators and Expressions
Lesson 5 of 30

Operators and Expressions

Arithmetic, comparison, logical, and assignment operators in Python.

Arithmetic Operators

OperatorSymbolExampleResult
Addition+7 + 310
Subtraction-7 - 34
Multiplication*7 * 321
Division/7 / 32.333…
Floor division//7 // 32
Modulus%7 % 31
Exponentiation**2 ** 8256

Comparison Operators

x = 10
print(x == 10)   # True
print(x != 5)    # True
print(x > 8)     # True
print(x <= 10)  # True

Logical Operators

a, b = True, False
print(a and b)   # False
print(a or b)    # True
print(not a)      # False

Assignment Operators

n = 10
n += 5    # n = 15
n -= 3    # n = 12
n *= 2    # n = 24
n //= 4   # n = 6
n **= 2   # n = 36

Operator Precedence

Python follows standard mathematical precedence: PEMDAS — Parentheses, Exponentiation, Multiplication/Division, Addition/Subtraction.

result = 2 + 3 * 4     # 14, not 20
result = (2 + 3) * 4   # 20