Numeric (Arithmetic) Operators in Python

Perform calculations with integers and floats

Operator Overview

Operator Name Description Example
+AdditionAdds two numbers3 + 2 → 5
-SubtractionSubtracts right side from left5 - 1 → 4
*MultiplicationMultiplies numbers4 * 2 → 8
/DivisionTrue division (float)5 / 2 → 2.5
//Floor DivisionDivides & rounds down5 // 2 → 2
%ModulusRemainder of division5 % 2 → 1
**ExponentiationPower operator2 ** 3 → 8

Basic Examples

a = 10
b = 3

print(a + b)   # 13
print(a - b)   # 7
print(a * b)   # 30
print(a / b)   # 3.333...
print(a // b)  # 3
print(a % b)   # 1
print(a ** b)  # 1000

Working with Floats

x = 7.5
y = 2.0

print(x * y)   # 15.0
print(x / y)   # 3.75
print(x // y)  # 3.0  (still float)
print(x % y)   # 1.5

Operator Precedence

Order of evaluation (highest → lowest): **, unary +/-, * / // %, + -. Use parentheses for clarity.

result = 3 + 2 * 4      # 11
result = (3 + 2) * 4    # 20
result = 2 ** 3 ** 2    # 512 (evaluates right‑to‑left)

Best Practices

Handy Built‑ins

print(abs(-7))            # 7
print(round(3.14159, 2))  # 3.14
print(pow(2, 5))          # 32 (same as 2 ** 5)
print(divmod(17, 5))      # (3, 2) → quotient & remainder