Arithmetic Operators
'''
Python has different types of operators. To create a calculator we require arithmetic operators.
Operator Operator Name Example
+ Addition 24+9
- Subtraction 24-9
* Multiplication 24*9
/ Division 24/9
// Floor Division 24//9
% Modulus 24%9
** Exponent 24**9
'''
a=24
b=9
print('Addition of' ,a, 'and' ,b, 'is' ,a+b)
#output:Addition of 24 and 9 is 33
print('Subtraction of' ,a, 'and' ,b, 'is' , a-b)
#output:Subtraction of 24 and 9 is 15
print('Multiplication of' ,a, 'and' ,b, 'is' ,a*b)
#output:Multiplication of 24 and 9 is 216
print('Division of' ,a, 'and' ,b, 'is' ,a/b)
#output:Division of 24 and 9 is 2.66665
print('Floor Division of' ,a, 'and' ,b, 'is' ,a//b)
#output:Floor Division of 24 and 9 is 2
#Floor division is the division that results into whole number adjusted to the left in the number line.
print('Modulus of' ,a, 'and' ,b, 'is' ,a%b)
#output:Modulus of 24 and 9 is 6
#Modulus is the remainder of the division of two numbers.
print('Exponent of' ,a, 'and' ,b, 'is' ,a**b)
#output:Exponent of 24 and 9 is 2641807540224
#Exponent is the power of a number.
Comments
Post a Comment