May 2017
Intermediate to advanced
280 pages
6h 2m
English
Python supports bitwise operations. You might have come across AND, OR, or complementary operations:
|
Operator |
Description |
|
| |
Performs binary OR operation |
|
& |
Performs binary AND operation |
|
~ |
Performs binary XOR operation |
|
^ |
Performs binary one's complement operation |
|
<< |
Left shift operator: The left-hand side operand bit is moved left by the number specified on the right-hand side |
|
>> |
Right shift operator: The left-hand side operand bit is moved right by the number specified on the right-hand side |
The following screenshot illustrates the various usages of bitwise operators:

~x will give ...
Read now
Unlock full access