Home >>Python Tutorial >Learn Python Operators

**Bitwise operators****Arithmetic operators****Membership operators****Assignment operators****Identity operators****Comparison operators****Logical operators**

Operators |
Name |
Example |

+ | Addition | x + y |

- | Subtraction | x – y |

* | Multiplication | x * y |

/ | Division | x / y |

% | Modulus | x % y |

** | Exponentiation | x ** y |

// | Floor Division | x // y |

Operators |
Example |
Same As |

= | x = 5 | x = 5 |

+= | x += 2 | x = x + 2 |

-= | x -= 2 | x = x – 2 |

*= | x *= 2 | x = x * 2 |

/= | x /= 2 | x = x / 2 |

%= | x %= 2 | x = x % 2 |

//= | x //= 2 | x = x // 2 |

**= | x **= 2 | x = x ** 2 |

&= | x &= 2 | x = x & 2 |

I = | x I = 2 | x = x I 2 |

^ = | x ^= 2 | x = x ^ 2 |

>> = | x >> = 2 | x = x >> 2 |

<< = | x<< = 2 | x = x << 2 |

Operator |
Name |
Example |

== | Equal | x == y |

!= | Not Equal | x != y |

> | Greater Than | x > y |

< | Less Than | x < y |

>= | Greater Than or Equal To | x >= y |

<= | Less Than or Equal To | x <= y |

Operator |
Description |
Example |
Try It |

and | Returns true if both statements are true | x < 3 and x < 10 | |

or | Returns true if one of the statements is true | x < 5 or x < 3 | |

not | Reverse the result, return false if the result is true | not( x < 3 and x < 10) |

Operator |
Description |
Example |

is | Returns true if both the variables are the same object | x is y |

is not | Returns true if both the variables are not the same object | x is not y |

Operator |
Description |
Example |

in | Returns true if the sequence with the specified value is present in the object | x in y |

not in | Returns true if the sequence with the specified value is not present in the object | x not in y |

Operator |
Name |
Description |

& | AND | Sets each bit to 1 if both bits are 1 |

I | OR | Sets each bit to 1 if one of two bits is 1 |

^ | XOR | Sets each bit to 1 if only one of the two bits is 1 |

~ | NOT | Inverts all the bits |

<< | Zero fill left shift | Shift left by pushing zeros in from the right and let the leftmost bits fall off |

>> | Signed right shift | Shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bit fall off |

Python Tutorial
Python Introduction
Getting Started With Python
Learn Python Syntax
Python Variables
Python Casting With Example
The Python Numbers Exercises
Python String
Learn Python Operators
Python List
Python Tuples
Python Set Operations
Python Dictionary
Python Conditions
For Loops Python
While Loop in Python
The Python Functions
The Python Array
Python Lambda
Python Classes and Objects
The Python Iterators
The Python Modules
Python Datetime
Python JSON
The Python PIP
Regular Expression in Python
File Handling in Python
Python Read File
Python Create File
Python Delete File
Getting Started With Python MySQL
Python Mysql Create Database
Python MySQL Create Table
Python MySQL – Insert into Table
Python MySQL – Select From Table
Python MySQL Where
Python MySQL Order By
Pyhton Mysql Delete
Python Mysql Drop Table
Python MySql Update Table
Python SQL Query Limit
Python Mysql Join Query
Python Built-in Exceptions