Arithmetic operators in python are used to perform arithmetic operations such as addition, subtraction, multiplication, and division on one or more numbers. These operators can be used on two operands or more.
Table of Contents
Arithmetic operators in python are used to perform arithmetic operations such as addition, subtraction, multiplication, and division on one or more numbers. These operators can be used on two operands or more.
Types of Arithmetic Operators
There are seven types of arithmetic operators in python language.
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Modulus (%)
- Exponentiation (**)
- Floor division (//)
i) Addition (+)
The symbol of addition in python language is +.
num_1 = 43
num_2 = 36
addition = num_1 + num_2
print("The addition of the numbers is: ", addition)
Output:
The addition of the numbers is: 79
ii) Subtraction (-)
The symbol of subtraction in python language is –.
num_1 = 120
num_2 = 23
subtraction = num_1 - num_2
print("The subtraction of the numbers is: ", subtraction)
Output:
The subtraction of the numbers is: 97
iii) Multiplication (*)
The symbol of multiplication in python language is *.
num_1 = 4
num_2 = 5
multiplication = num_1 * num_2
print("The multiplication of the numbers is: ", multiplication)
Output:
The multiplication of the numbers is: 20
iv) Division (/)
The symbol of division in python language is /.
num_1 = 100
num_2 = 3
division = num_1 / num_2
print("The division of the numbers is: ", division)
Output:
The division of the numbers is: 33.333333333333336
v) Modulus (%)
The symbol of modulus in python language is %.
num_1 = 23
num_2 = 4
modulus = num_1 % num_2
print("The modulus of the numbers is: ", modulus)
Output:
The modulus of the numbers is: 3
vi) Exponentiation (**)
The symbol of exponentiation in python language is **.
num_1 = 2
num_2 = 4
exponentiation = num_1 ** num_2
print("The exponentiation of the numbers is: ", exponentiation)
Output:
The exponentiation of the numbers is: 16
vii) Floor Division (//)
The symbol of floor division in python language is //.
num_1 = 100
num_2 = 3
floor_division = num_1 // num_2
print("The floor division of the numbers is: ", floor_division)
Output:
The floor division of the numbers is: 33
Read the full details of Python Operators in this article: