Arithmetic Operators in Python

 

Arithmetic Operators in Python



Python programming has collection of operators to perform various operations.an operators is a symbols which operates on value or variables.

Arithmetic Operator   : Arithmetic operators are the binary operators. Arithmetic operators are used to perform mathematical operations. Addition , Subtraction ,Multiplication ,Division are the basic operation performed by the arithmetic operators.

Operator

Name

Syntax

+

Addition : Use to add two operands

X + Y

-

Subtraction: Use to subtracts two operands.

X – Y

*

Multiplication : Use to multiply two operands.

X * Y

/

Division : Use to divide two operands.

X / Y

%

Modulus : Use to returns the value of remainder after dividing two operands.

X % Y

**

Exponentiation (power) : Use for calculating the 1st operand to the power of 2nd.

X ** Y

//

Floor division : Use to return the value of quotient after dividing two operands.

X // Y

 

# example of arithmetic operator

a = 20;

b = 10;

c = a + b;

print ("Addition Value: ",c)

c = a - b;

print ("Subtraction value: ",c)

c = a * b;

print ("Multiplication Value: ",c)

c = a / b;

print ("Division Value: ",c)

c = a % b;

print ("Mod Value: ",c)

c = a**b;

print ("Exponent Value: ",c)

c = a//b;

print ("Floor Division Value: ",c)

Output :

Addition Value:  30

Subtraction value:  10

Multiplication Value:  200

Division Value:  2.0

Mod Value:  0

Exponent Value:  10240000000000

Floor Division Value:  2


 Conclusion : Here we see that by using arithmetic operator we can do the mathematical operation in python. 

 

 

Comments

Post a Comment

Popular posts from this blog

Data Types In Python

Assignment Operators in Python

Installation Of Python