What Are Arithmetic Operators?
Arithmetic operators are used to perform mathematical operations on numbers.
1. Addition (+)
Adds two numbers.
a = 10
b = 5
result = a + b
print("Addition:", result) # Output: 15
2. Subtraction (-)
Subtracts the second number from the first.
a = 10
b = 5
result = a - b
print("Subtraction:", result) # Output: 5
3. Multiplication (*)
Multiplies two numbers.
a = 10
b = 5
result = a * b
print("Multiplication:", result) # Output: 50
4. Division (/)
Divides the first number by the second and returns a float.
a = 10
b = 5
result = a / b
print("Division:", result) # Output: 2.0
Even if both numbers are integers, result is float.
5. Floor Division (//)
Divides and returns the integer part (no decimals).
a = 10
b = 3
result = a // b
print("Floor Division:", result) # Output: 3
6. Modulus (%)
Returns the remainder of division.
a = 10
b = 3
result = a % b
print("Modulus:", result) # Output: 1
7. Exponentiation (**)
Raises the first number to the power of the second.
a = 2
b = 3
result = a ** b # 2 raised to power 3
print("Exponentiation:", result) # Output: 8
Full Example (All Together)
x = 9
y = 4
print("Addition:", x + y) # 13
print("Subtraction:", x - y) # 5
print("Multiplication:", x * y) # 36
print("Division:", x / y) # 2.25
print("Floor Division:", x // y) # 2
print("Modulus:", x % y) # 1
print("Exponent:", x ** y) # 6561
Summary Table
Operator Symbol Description Example Result
Addition + Adds values 3+2 5
Subtract - Subtracts values 3-2 1
Multiply * Multiplies values 3*2 6
Divide / Divides values 3/2 1.5
Floor Div // Integer division 3 // 2 1
Modulus % Remainder of division 3 % 2 1
Exponent ** Power operation 3 ** 2 9