Arithmetic operators and Comparison Operators in Python

Arithmetic operators and Comparison Operators  in Python

Operators are the special symbols that are used to manipulate the value of operands. Example +,-,*,/,%^
In an expression ,an operator is used on operands

Arithmetic Operators :

Arithmetic operators are used with numeric values to perform common mathematical operations like addition, subtraction, Multiplication and division. User can apply these operators on the numbers as well as on variables to perform various arithmetic Operations . 
Consider two variables x and y for below table in which values of them are 

x=70

y=50


Operators 

Description 

Example 

+

Adds the operands 

x+y=120

-

Subtract the operand on the right from operand from left 

x-y=20

*

Multiples the two operands 

x*y=3500

/

Divide operand on the left side of the operand on right side 

x/y=1.4

%

Modulus : It will perform the division first and then return the reminder 

x%y=20

//

Floor Division . Divide the operand and return the quotient. It will removes digits after the decimal point.

x//y=1

**

Perform the exponential operation 

x**y=x to the power y


Comparison Operators :


Comparison operators are also called as relational operators are used to compare the values on its either sides and determine the relation between them. Result of comparison operators is in the form of True and False .

Consider two variables x and y for below table in which values of them are 

x=70

y=50



Operator

Description

Example 

==

Return true if the two values are exactly same

x==y   false

!=

Return True if the values are not equal .

x!=y true

>

Turn if the operand on the left side is greater than the operand on the right side .

x>y  true 

<

True if the operand on the right side is greater than the left side .

x<y false

>=

Return true if the operand on left side is either greater or equal to the right side operand 

x>=y true

<=

Return true if the operand on the right  side is either greater or equal to that of the left side operand 

X <=y false


Comparison operators are mainly used in the loops expression(conditions)