Arithmetic Operator:

The Python arithmetic operator’s operator work on two operands.
An arithmetic operator performs mathematical operations such as addition, subtraction, multiplication, division etc. on numerical values (constants and variables).

Addition(+): + Operator is used to perform addition of two variable or operands.
e.g z=x+y

Substaction(-): - Operator is used to perform substraction of two variable or operands.
e.g z=x-y


Multiplcation(*): - Operator is used to perform multiplication of two variable or operands. e.g z=x*y

Division(/): - Operator is used to perform Division of two variable or operands. e.g z=x/y

Modulus or Modulo(%): - Operator is used to perform modulo division (or finds the remainder)of two variable or operands.
e.g z=x%y

Exponentiation(**): - In Python Exponentiation Operator is used to calculate exponential value of the given base and exponent values. We use the (**) double asterisk/exponentiation operator between the base and exponent values.
e.g z=z**y
Floor Division(//): - Floor Division Operator(//)In Python is used to calculate Floor Division - The division of operands where the result is the quotient in which the digits after the decimal point are removed. But if one of the operands is negative, the result is floored, i.e., rounded away from zero (towards negative infinity) −
e.g.
x=9
y=2
x//y     # 9//2=4

Example 1: Arithmetic Operators in Python Language


Let undestand the arithmetic operator using following example with explanation.
# Working of arithmetic operators in Python Scripting language

x = 9         // variable assigned values i.e x=9,y=4
y = 4
z = x+y;
print("x+y = ",z);
z = x-y;
print("x-y= ",z);
z = x*y;
print("x*y = ",z);
z = x/y;
print("x/y = ",z);`
z = x%y;
print("Remainder when",x," divided by ",y,"=",z);
z=x//y
print("x//y=",z)
z=x**y
print("x**y=",z)

Output
x+y = 13
x-y = 5
x*y = 36
x/y = 2.25
Remainder when 9 divided by 4=1
x//y=2
x**y=6561

Program Explanation:
The Arithmetic operators +, - ,*,/,%,//,** computes addition, subtraction, and multiplication, division , remainder,floor division and exponentiation respectively.
In our program the value of variables i.e. integer variable are x=9 and y=4 respectively.
The addition performed z=x+y is 13
The subtraction performed z=x-y is 5
The multiplication performed z=x*y is 36
The division performed z=x/y is 2.25
And
The Remainder performed z=x%y is 1
The floor division performed x//y is 2
The exponetiation x raise to the power y is 6561
x**y=6561 In normal in our day to day life the calculation 9/4 = 2.25. and Python gives it as 2.25.
Next The modulo operator is used to compute remainder in the programming. Here % operator computes the remainder.
When the variable x=9 is divided by the variable y=4, the remainder is 1.


Next Topic:
Assignment Operators