Python Arithmetic Operators
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, division, and more on numbers.
1. Addition (+
)
Adds two numbers.
a = 10
b = 5
result = a + b
print(result) # Output: 15
2. Subtraction (-
)
Subtracts the right operand from the left.
a = 10
b = 5
result = a - b
print(result) # Output: 5
3. Multiplication (*
)
Multiplies two numbers.
a = 10
b = 5
result = a * b
print(result) # Output: 50
4. Division (/
)
Divides the left operand by the right operand and returns a float.
a = 10
b = 4
result = a / b
print(result) # Output: 2.5
print(type(result)) # <class 'float'>
5. Floor Division (//
)
Divides and returns the integer part (floor value) of the quotient.
a = 10
b = 4
result = a // b
print(result) # Output: 2
print(type(result)) # <class 'int'>
6. Modulus (%
)
Returns the remainder of the division.
a = 10
b = 4
result = a % b
print(result) # Output: 2
7. Exponentiation (**
)
Raises the left operand to the power of the right operand.
a = 2
b = 3
result = a ** b
print(result) # Output: 8 (2³ = 8)
Summary Table
Operator | Description | Example | Result |
---|---|---|---|
+ |
Addition | 5 + 3 |
8 |
- |
Subtraction | 5 - 3 |
2 |
* |
Multiplication | 5 * 3 |
15 |
/ |
Division (float result) | 5 / 2 |
2.5 |
// |
Floor Division (int result) | 5 // 2 |
2 |
% |
Modulus (remainder) | 5 % 2 |
1 |
** |
Exponentiation | 2 ** 3 |
8 |
At Online Learner, we're on a mission to ignite a passion for learning and empower individuals to reach their full potential. Founded by a team of dedicated educators and industry experts, our platform is designed to provide accessible and engaging educational resources for learners of all ages and backgrounds.
Terms Disclaimer About Us Contact Us
Copyright 2023-2025 © All rights reserved.