Operators in python


Operator

      Operators are used to perform operations on variable and values. Operators are the constructs which can manipulate the value of operands.

Example :      4+5=9   

                      Here 4 and 5 are called operands and + is called operator.

Types of operator

      Python Language supports the following types of operators:-

  1. Arithmetic Operators
  2. Comparison Operators
  3. Assignment Operators
  4. Logical operators
  5. Bitwise Operators
  6. Identity Operators
  7. Membership operators

Arithmetic Operators 

These operators are used to perform arithmetic operations such as addition, subtraction,multiplication,division etc.

      List of arithmetic operators


Comparison Operators        

            These operators are used to compare values. It is also called relational operators. The result of these operator is always a Boolean value means , True or False.           
                                    
                                                      List of comparison operators
     

                                                                                      

Assignment Operators

             This operator is used to store right side operands in the left side operands. this operators are used to assign values to variables.

   List of assignment operators



Logical Operators

       These operators are used to check two or more conditions. The resultant of this operator is always a Boolean value. Here x and y are two operands that store either true or false Boolean values.

       List of logical operators



Bitwise Operator

       These operators perform bit level operation on operands. Let us take two operand x=10 and y=12. In binary format this can be written as x=1010 and y=1100.

 List of bitwise operators


Identity Operator

            These operator are used to check whether both operands are same or not. Suppose x stores a value 20 and y stores a value 40. Then x is y return false and x not is y return true.

List of identity operators


Membership Operator

               These operators are used to check an item or an element that is part of a string, a list or a tuple. A membership operator reduces the effort of searching an element in the list. Suppose x stores a value 20 and y is the list containing items 10,20,30 and 40. Then x is a part of the list y because the value 20 is in the list y.

List of membership operators
















No comments:

Post a Comment