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 |
Your Feedback
Help us improve by sharing your thoughts
Online Learner helps developers master programming, database concepts, interview preparation, and real-world implementation through structured learning paths.
Quick Links
© 2023 - 2026 OnlineLearner.in | All Rights Reserved.
