- Himanshu Ramchandani
- Posts
- What are Arithmetic Operators in Python Exactly?
What are Arithmetic Operators in Python Exactly?
Computers integrate all mathematical operations, called Arithmetic Operators.
#WrittenByHuman
Arithmetic Operators - Himanshu Ramchandani
+ - * / % // **
Addition
Subtraction
Multiplication
Divide
Modulo
Floor Division
Exponential
Addition
print(10 + 20)
30
Substruction
print(20 - 10)
10
Multiplication
print(3 * 5)
15
Divide
print(7/2)
3.5
Modulo
This will do the normal division and return the remainder as in mathematics.
print(7%2)
3
print(14 % 8)
6
Floor Division
This will return a quotient, or you can say it will return the integer and ignore the decimal part.
print(7 // 2)
3
print(8 // 3)
2
Exponential
It is just the power. Here 2 to the power 3 that will be 8.
print(2 ** 3)
8
print(7 ** 3) # this will be 7 to the power 3
343
That’s it for the Arithmetic Operators.
Reply