Operators in Python

Python operators allow programmers to manipulate data or operands. Here are the types of operators supported by Python:

• Arithmetic Operators
• Assignment Operators
• Relational or Comparison Operators
• Logical Operators
• Identity Operators
• Bitwise Operators
• Membership Operators

Arithmetic Operators:

 Operator Description Example + Addition adds the value of the left and right operands >>> 10+5 15 - Subtraction subtracts the value of the right operand from the value of the left operand >>> 10-5 10 * Multiplication multiplies the value of the left and right operand >>> 10*5 50 / Division divides the value of the left operand by the right operand >>> 10/5 2 ** Exponent performs exponential calculation >>>2**3 2 raised to the power of 3 8 % Modulus returns the remainder after dividing the left operand with the right operand >>>17 % 5 2 // Floor Division division of operands where the solution is a quotient left after removing decimal numbers >>>17 // 5 3

Assignment Operators :

These operators are useful when assigning values to variables:

 Operators Description Example = assigns the value of the right operand to the left operand a = c a = b + c a = 8 += add and adds the value of the right and left operand and assigns the total to the left operand x = x += a -= subtract and deducts the value of the right operand from the value of the left operand and assigns the new value to the left operand x = x-=a *= multiply and multiplies the left and right operand and assigns the product to the left operand x = x*=a /= divide and divides the left operand with the value of the right operand and assigns the quotient to the left operand x = x/a **= exponent performs exponential operation on the left operand and assigns the result to the left operand x%=a //= floor division and performs floor division on the left operand and assigns the result to the left operand x = x//a

Relational or Comparison Operators :

Relational operators evaluate values on the left and right side of the operator and return the relation as either True or False.

 Operator Description == is equal to < is less than > is greater than <= is less than or equal to >= is greater than or equal to != is not equal to