Arithmetic Operators
3 min read ·
Arithmetic operators in Python are used to perform mathematical calculations.
They work with numeric data types such as
int, float, and complex.These operators are fundamental and used in almost every Python program.
What Are Arithmetic Operators?
Arithmetic operators perform basic math operations between two operands.
Types of Arithmetic Operators
| Operator | Name | Description |
|---|---|---|
+ | Addition | Adds two values |
- | Subtraction | Subtracts second value from first |
* | Multiplication | Multiplies two values |
/ | Division | Divides two values |
% | Modulus | Returns remainder |
** | Exponentiation | Power operation |
// | Floor Division | Returns quotient without decimals |
Addition (+)
Adds two numbers.
Subtraction (-)
Subtracts one number from another.
Multiplication (*)
Multiplies two numbers.
Division (/)
Always returns a float value, even if the division is exact.
Modulus (%)
Returns the remainder of a division.
Exponentiation (**)
Raises a number to the power of another.
Floor Division (//)
Returns the integer part of the division result.
Important
Floor division rounds down to the nearest whole number.
Arithmetic Operators with Variables
Arithmetic Operators with Negative Numbers
Operator Precedence in Arithmetic
Python follows BODMAS/PEMDAS rule.
Tricky Arithmetic Examples (Interview)
Common Mistakes
Expecting Integer Result from /
Correct Way
Practice
- Perform all arithmetic operations on two numbers
- Find square root using exponentiation
- Predict output of negative floor division
- Solve expressions using operator precedence