Arithmetic Operation in Python
Arithmetic Operation in Python
Symbol | Description | Example 1 | Example 2 |
+ | Addition | >>>55+45 100 | >>> „Good‟ + „Morning‟ GoodMorning |
- | Subtraction | >>>55-45 10 | >>>30-80 -50 |
* | Multiplication | >>>55*45 2475 | >>> „Good‟* 3 GoodGoodGood |
/ | Division | >>>17/5 3 >>>17/5.0 3.4 >>> 17.0/5 3.4 | >>>28/3 9 |
% | Remainder/Modulo | >>>17%5 2 | >>> 23%2 1 |
** | Exponentiation | >>>2**3 8 >>>16**.5 4.0 | >>>2**8 256 |
// | Integer Division | >>>7.0//2 3.0 | >>>3/ / 2 1 |
#Demo Program to test Arithmetic Operators a=100 b=10 print ("The Sum = ",a+b) print ("The Difference = ",a-b) print ("The Product = ",a*b) print ("The Quotient = ",a/b) print ("The Remainder = ",a%30) print ("The Exponent = ",a**2) print ("The Floor Division =",a//30) #Program End
Output:
The Sum = 110
The Difference = 90
The Product = 1000
The Quotient = 10.0
The Remainder = 10
The Exponent = 10000
The Floor Division = 3