Python Arithmetic Operators
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division.
There are 7 arithmetic operators in Python :
- Addition
- Subtraction
- Multiplication
- Division
- Modulus
- Exponentiation
- Floor division
1. Addition Operator : In Python, + is the addition operator. It is used to add 2 values.
Example :
val1 = 2val2 = 3 # using the addition operatorres = val1 + val2print(res) |
Output :
5
2. Subtraction Operator : In Python, – is the subtraction operator. It is used to subtract the second value from the first value.
Example :
val1 = 2val2 = 3 # using the subtraction operatorres = val1 - val2print(res) |
Output :
-1
3. Multiplication Operator : In Python, * is the multiplication operator. It is used to find the product of 2 values.
Example :
val1 = 2val2 = 3 # using the multiplication operatorres = val1 * val2print(res) |
Output :
6
4. Division Operator : In Python, / is the division operator. It is used to find the quotient when first operand is divided by the second.
Example :
val1 = 3val2 = 2 # using the division operatorres = val1 / val2print(res) |
Output :
1.5
5. Modulus Operator : In Python, % is the modulus operator. It is used to find the remainder when first operand is divided by the second.
Example :
val1 = 3val2 = 2 # using the modulus operatorres = val1 % val2print(res) |
Output :
1
6. Exponentiation Operator : In Python, ** is the exponentiation operator. It is used to raise the first operand to power of second.
Example :
val1 = 2val2 = 3 # using the exponentiation operatorres = val1 ** val2print(res) |
Output :
8
7. Floor division : In Python, // is used to conduct the floor division. It is used to find the floor of the quotient when first operand is divided by the second.
Example :
val1 = 3val2 = 2 # using the floor divisionres = val1 // val2print(res) |
Output :
1
Below is the summary of all the 7 operators :
| Operator | Description | Syntax |
|---|---|---|
| + | Addition: adds two operands | x + y |
| – | Subtraction: subtracts two operands | x – y |
| * | Multiplication: multiplies two operands | x * y |
| / | Division (float): divides the first operand by the second | x / y |
| // | Division (floor): divides the first operand by the second | x // y |
| % | Modulus: returns the remainder when first operand is divided by the second | x % y |
| ** | Power : Returns first raised to power second | x ** y |






Please Login to comment...