Back to Python Notes
Topic #33

Bitwise Operators

Bitwise operators work on the individual bits of integers, and they underpin compression, hashing and low-level work. Rare in apps, essential in interviews.


Bitwise Operators

Bitwise operators are used to compare (binary) numbers:

Operator Name Description Example Try it
& AND Sets each bit to 1 if both bits are 1 x & y
| OR Sets each bit to 1 if one of two bits is 1 x | y
^ XOR Sets each bit to 1 if only one of two bits is 1 x ^ y
~ NOT Inverts all the bits ~x
<< Zero fill left shift Shift left by pushing zeros in from the right and let the leftmost bits fall off x << 2
>> Signed right shift Shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off x >> 2

Examples

Example

print(6 & 3)

Example

print(6 | 3)

Example

print(6 ^ 3)

Want to go beyond the notes?

Join Coding Now Tech Institute's Python course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Bitwise Operators – FAQs

Quick answers about learning Bitwise Operators in Python.

This free note from Coding Now Tech Institute explains Bitwise Operators in Python — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Python topic on Coding Now Tech Institute, including Bitwise Operators, is 100% free with no signup required.
With focused practice, most students grasp Bitwise Operators in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now