# Python Bitwise Operators

## Bitwise Operators

Bitwise Operators are used to perform gate operations like AND, OR, NOT, XOR, etc., at bit level data.

The following tables presents all the Bitwise Operators available in Python, with respective operator symbol, description, and example.

## Examples

In the following program, we take numeric values in x, y; and perform bitwise operations.

Python Program

``````x = 12
y = 5

print(f'x & y  : {x & y}')
print(f'x | y  : {x | y}')
print(f'~x     : {~x}')
print(f'x ^ y  : {x ^ y}')
print(f'x << y : {x << y}')
print(f'x >> y : {x >> y}')``````
Run Code Copy

Output

``````x & y  : 4
x | y  : 13
~x     : -13
x ^ y  : 9
x << y : 384
x >> y : 0
``````

## Bitwise Operators Tutorials

The following tutorials provide syntax, usage, and examples, for each of the Bitwise Operators in detail.

## Summary

In this tutorial of Python Examples, we learned about Bitwise Operators, and how to use them in programs for bit level operations: AND, OR, NOT, XOR, Left Shift, and Right Shift.

## Related Tutorials

Code copied to clipboard successfully 👍