Skip to content
Learnearn.uk » Home » Arithmetic, Relational & Logical Operators

Arithmetic, Relational & Logical Operators

Arithmetic Operators

Arithmetic Operators

Arithmetic operators can be used in Python to perform various arithmetic operations on numeric values and variables.

Operator Description Example
+ Addition 3 + 5 = 8
- Subtraction 7 - 2 = 5
* Multiplication 4 * 3 = 12
/ Division 10 / 2 = 5.0
// Floor Division 10 // 3 = 3
% Modulus (Remainder) 10 % 3 = 1
** Exponentiation 2 ** 3 = 8
+= Increment x += 5
-= Decrement x -= 3
*= Multiplication Assignment x *= 2
/= Division Assignment x /= 4

Examples

# Addition
result = 5 + 3
print(result)   # 8

# Subtraction
result = 7 - 2
print(result)   # 5

# Multiplication
result = 4 * 3
print(result)   # 12

# Division
result = 10 / 2
print(result)   # 5.0

# Floor Division
result = 10 // 3
print(result)   # 3

# Modulus (Remainder)
result = 10 % 3
print(result)   # 1

# Exponentiation
result = 2 ** 3
print(result)   # 8

# Increment
x = 5
x += 1
print(x)       # 6

# Decrement
y = 7
y -= 1
print(y)       # 6

# Multiplication Assignment
z = 4
z *= 3
print(z)       # 12

# Division Assignment
w = 10
w /= 2
print(w)       # 5.0

Relational Operators

Logical Operators