OPERATORS:-

  • Operator is symbol that performs certain  operations.
  • Python provides  the following set of operators.
1. Arithmetic Operators
2. Relational Operators OR Comparison Operators
3. Logical Operators
4. Bitwise Operators
5. Assignment Operators
6. Special Operators

1. Arithmetic Operators:- 
                                             Arithmetic operators using to perform mathematical Arithmetic operator likes

  • Addition  (+)
  • Subtraction (-)
  • Multiplication (*)
  • Division Operator (/)
  • Modulo Operator (%)
  • Floor Division operator (//)
  • Exponent Operator OR Power Operator (**)
Eg:-
        a=10
        b=2
        print(a+b)
        print(a-b)
        print(a*b)
        print(a/b)
        print(a//b)
        print(a%b)
        print(a**b)
Output:
              12
              8
              20
              5.0
              5
              0
             100

2. Comparison Operators:
                                           Comparison Operator are use to compare the data of the object which are pointed the operations.(give True and False value)

Comparison Operator Symbols:

  •  >, >=, <, <=, =
Eg:-
       a=19
       b=4
       print(a>b)
       print(a>=b)
       print(a<b)
       print(a<=b)
Output:
              True
              True
              False
              False

3. Logical Operators:
                                     Logical operator are used to perform mathematical logical operation like
      Logical AND ,Logical OR and Logical NOT operation.(give True and False value)

Eg:-
        a=True
        b=False
        print(a and b)
        print(a or b)
        print( not b)
Output:
              False
              True
              True
4. Bitwise Operators:
                                     Bitwise operator represented Binary formate,perform of operation binary data   and used the result of decimal formate.

Bitwise Operator Symbols: 

  • &, |,^,~ ,<<, >>
Eg:-
       a=10
       b=4
       print(a&b)
       print(a|b)
       print(a^b)
       print(~a)
       print(a>>2)
       print(a<<2)
Output:
              0
              14
              14
             -11
               2
              40
NOTE:-
              A>>2:- Removeing two digit in right side and add the left side.
              A<<2:- Removeing two digit in left side and add the right side.

5. Assignment Operators:-
                                              Assignment Operators use to assign the data to variables are operator.

The following is the list of all possible compound assignment operators on python
  • =
  • +=
  • -=
  • /=
  • %=
  • //=
  • **=
  • &=
  • |=
  • ^=
  • >>=
  • <<=
Eg1:-
         x=10
         x+=20
         print(x)
Output:
              30
Eg2:-
         x=10
         x&=20
         print(x)
Output: 
              0

6. Special Operators:-
    Python supports two types of special operator.
            1) Identity Operators
            2) Membership Operators

 1) Identity Operators:
  • Identity Operators are used to comparison the address.
  • Python supports two types of Identity operator.
             1) IS
             2) IS NOT
Eg:-
          a=10
          b=4
          print(a is b)
          print(a is not b)
Output:
              False
              True
 2) Membership Operators:
  • Membership Operators are used to check whether the given object present in the given collection.
  • Python support two types of Membership operator.
              1) IN
              2) NOT IN
Eg:-
        x="rahul"
        print(x)
        print('h' in x)
        print('h' not in x)
        print('e' in x)
        print('e' not in x)
Output:
               rahul
               True
               False
               False
               True