Math operators:
- In python, we have various arithmetic operators.
- These are called math operators because they perform different types of mathematical operations.
- Here we have seven types of arithmetic operators:
- + addition
- - subtraction.
- / division.
- % modulus.
- * multiplication.
- // floor division.
- ** exponential.
1.Addition(+): It is used to add two or more operands.
It is represented by the "+". symbol.
syntax:(a+b).
2.subtraction(-): It subtracts the value of the one operand to other operands
It is represented by the symbol "-".
syntax:(a-b).
3.Division(/): It divides one operand with another operand and gives the remainder. The result is always in float type only.
It is represented by the symbol "/'.
syntax:(a/b).
4.modulus(%): It is the remainder of the operands.
It is represented by the symbol "%".
syntax:(a%b).
5.Multiplication(*): It multiply the two or more operands.
It is represented by the symbol "*".
syntax:(a*b).
6.floor division(//): It divides the operands and get the result in the whole number only.
It is represented by the symbol "//'.
syntax:(a//b).
7.exponential(**): It is used to calculate the power of the values.
It is represented by the symbol "**'.
syntax:(a**b).
Example: write a python program for integers using math operators.
- x=3
- y=4
- print(x+y)
- print(x-y)
- print(x/y)
- print(x%y)
- print(x*y)
- print(x//y)
- print(x**y)
output: 7
-1
0.75
3
12
0
81
No comments