♦ Python Operators
♣ About Python OperatorsOperators in Python are fundamentally used to perform operations on Variables and Values.
Various types of Operators exist in Python.
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Identity Operators
- Membership Operators
- Bitwise Operators
♣ Example1: Arithmetic Operators in PythonArithmetic Operations in Python are used to perform Mathematical Operations.
♣ Example2: Assignment Operators in PythonAssignment Operations in Python are used for assignment of (values)/(variable values) to variables.
|>>=||Zero fill left shift Assignment|
|<<=||Signed right shift Assignment|
♣ Example3: Comparison Operators in PythonComparison Operators in Python are used to compare two Values/Variables.
|!=||Not Equal to|
|=>||Greater than or Equal to|
|=<||Less than or Equal to|
♣ Example4: Logical Operators in PythonLogical Operators in Python are used to evaluate conditional statements and produce Boolean output.
|and||returns True if all variables/statements are True|
|or||returns True if atleast one variables/statements are True|
|not||returns the reverse of Boolean value|
♣ Example5: Identity Operators in PythonIdentity Operators in Python are used to check whether a one or more variables share the same memory location, that is same value is assigned to multiple variables.
|is||returns true if both variables share the same memory-location(and also the value, ofcourse)|
|is not||returns true if both variables do not share the same memory-location(but may possibly have same value)|
♣ Example6: Membership Operators in PythonMembership Operators in Python are used to check if a particular value/sequence is present in an Object.
|in||returns True if a particular value/sequence is present in an Object|
|not in||returns True if a particular value/sequence is not present in an Object|
♣ Example7: Bitwise Operators in PythonBitwise Operators in Python are used to compare numbers which are represented in Binary format.
|&||Outputs 1 if both bit's value is 1|
||||Outputs 1 if atleast one of bit's value is 1|
|^||Outputs 1 if only one of bit's value is 1|
|~||Reverses the bit value|
|<<||Left Shift of 0s|
|>>||Right Shift of 0s|