- Python Arithmetic Operators.
- Python Comparison Operators
- Python Assignment Operators
- Python Bitwise Operators
- Python Logical Operators
- Python Membership Operators
- Python Identity Operators

Operator | Description |
---|---|

** | Exponent - Performs exponential (power) calculation on operators |

* | Multiplication |

/ | Division |

% | Modulus |

+ | Addition |

- | Subtraction |

The below figure shows the precedence order

Python Precedence order

Mixed-Mode conversion

Type conversion

Operator | Description |
---|---|

== | To check the equality |

< | Less than, Return true if left hand side of < is less than right hand side |

> | Greater than, Return true if left hand side of > is greater than right hand side |

<= | Less than or equal to, Return true if left hand side of <= is less than or equal to right hand side |

>= | Greater than or equal to, Return true if left hand side of >= is greater than or equal to right hand side |

!= | Not Equal to, Return true if Left hand side is not equal to right hand side |

<> | Not Equal to, Return true if Left hand side is not equal to right hand side |

Comparison Operator

Comparison Operator

Comparison between different data type

- Numbers are compared arithmetically.
- Strings are compared alphabetical order using the numeric equivalents.
- Tuples and lists are compared alphabetical order using comparison of corresponding elements, you will see detail of list, tuple dictionary in their corresponding page

Operator | Description |
---|---|

= | x=y , y is assigned to x |

+= | x+=y is equivalent to x=x+y |

-= | x-=y is equivalent to x=x-y |

*= | x*=y is equivalent to x=x*y |

/= | x/=y is equivalent to x=x/y |

**= | x**=y is equivalent to x=x**y |

Assignment Operator

Operator | Description |
---|---|

| | Perform binary OR operation |

& | Perform binary AND operation |

~ | Perform binary XOR operation |

^ | Perform binary one's Complement operation |

<< | Left shift operator, left side operand bit is moved left by numeric number specified in right side |

>> | Right shift operator, left side operand bit is moved right by numeric number specified in right side |

Bitwise Operator

Operator | Description |
---|---|

and | Return true if both right side and left side of operator are true. |

or | Return true if any side, either right side or left side of operator are true. |

not | If condition in not operator is true , not operator make it false. |

Bitwise Operator

Operator | Description |
---|---|

in | Return true if specified operand found in sequence. |

not in | Return true if specified operand not found in sequence. |

Membership Operator

Operator | Description |
---|---|

is | Return true, if two variables point the same object and false otherwise. |

is not | Return false, if two variables point the same object and true otherwise. |

The below figure shows value can be same, but id is different. Return true if Id is same.

Identity Operator

Operator | Description |
---|---|

( ) | Parentheses |

x[index],x[index1:index2],f(arg...),x.attribute | Subscription, slicing, call, attribute reference |

** | Exponentiation |

+x, -x, ~x | Positive, negative, bitwise NOT |

*, /, % | Multiplication, division, remainder |

+, - | Addition and subtraction |

<<, >> | Shifts |

& | Bitwise AND |

^ | Bitwise XOR |

| | Bitwise OR |

in, not in, is, is not, <, <=, >, >=, !=, == | Comparisons, including membership tests and identity tests |

not x | Boolean NOT |

and | Boolean AND |

or | Boolean OR |

if - else | Conditional expression |

lambda | Lambda expression |