Arithmetic Operators
Arithmetic Operators सात प्रकार के होते है |
| Arithmetic Operator | Sign | Description |
| Addition | + | left और right operand को add करता है | |
| Subtraction | - | left operand से right operand को subtract करता है | |
| Multiplication | * | left और right operand को multiply करता है | |
| Division | / | left operand से right operand को divide करता है | |
| Modulus | % | left operand से right operand को divide करके remainder return करता है | |
| Floor Division | // | left operand से right operand को divide करके floor value return करता है | |
| Exponent | ** | left operand का power right operand होता है | |
Addition Arithmetic Operator in Python
Source Code :
print(5 + 6)
print(5.6 + 7.9)
Output :
11
13.5
Subtraction Arithmetic Operator in Python
Source Code :
print(5 - 6)
print(5.6 - 7.9)
print(7.9 - 5.6)
Output :
-1
-2.3000000000000007
2.3000000000000007
Multiplication Arithmetic Operator in Python
Source Code :
print(5 * 6)
print(5.6 * 7.9)
print(7.9 * 5.6)
Output :
30
44.24
44.24
Division Arithmetic Operator in Python
Source Code :
print(5/2)
print(4/2)
print(4.6/2.6)
print(2/4)
print(0/4)
print(4/0)
Output :
2.5
2.0
1.769230769230769
0.5
0.0
print(4/0)
ZeroDivisionError: division by zero
Modulus Arithmetic Operator in Python
Source Code :
print(4%2)
print(4%5)
print(4%3)
print(4.5%3.5)
Output :
0
4
1
1.0
Floor Division Arithmetic Operator in Python
Source Code :
import math
print(4/3)
print(4//3)
print(math.floor(4/3))
print(3/4)
print(3//4)
print(math.floor(3/4))
Output :
1.3333333333333333
1
1
0.75
0
0
Exponent Arithmetic Operator in Python
Source Code :
import math
print(4**2)
print(math.pow(4, 2))
print(4**10)
print(math.pow(4, 10))
Output :
16
16.0
1048576
1048576.0
No comments: