Arithmetic Operators
Arithematic Operators are either symbols or elements to represent a specific mathematical function that is to be performed on values on variables in a python code.
Plus (+) Symbol
Addition:Return Sums of the operands.
Example:
In [1]:
#Addition
a = 345
b = 987
print(a+b)
1332
Minus (-) Symbol
Subtraction:Return Difference of the operands.
Example:
In [2]:
#Substraction
a = 500
b = 250
c = a - b
print(c)
250
Slash (/) Symbol
Division:Returns the quotient of the operands.
Example:
In [4]:
#Division
a = 81
b = 3
print(a/b)
27.0
Asteriks (*) Symbol
Multiplacation:Returns product of the operands.
Example:
In [5]:
#Multiplacation
a = 3.2
b = 4.3
c = 9.4
print(a*b*c)
129.344
Exponentation
Double Asteriks:Returns exponent of the base, like, 2 raised to 4 is 222*2=16.
Example:
In [6]:
a = 5
b = 3
print(a**b)
125
Modulus
Remainder of the divsion;Symbol: %.
In [7]:
a = 4
b = 21
print(b%a)
Floor Division (//)
Division without decimal value.
Example:
In [9]:
a = 253
b = 5
print(a//b)
50
In [ ]: