Module 3: Operators in Python
Bitwise Operators
Bitwise operators work on 0s and 1s at the bit level. They are used less often in everyday scripts but matter in systems and performance work.
About 10 minutes
- & AND
- | OR
- ^ XOR
- ~ NOT
- << left shift
- >> right shift
Example code
print(5 & 3) # 1 print(5 | 3) # 7 print(5 ^ 3) # 6 print(5 << 1) # 10
Learn what each operator does here; prioritize arithmetic and comparison operators in daily coding.
Practice
Run the example bitwise lines and observe the numbers printed.
Key takeaways
- Bitwise operators manipulate individual bits.
- Uncommon in typical application code.
- Arithmetic and comparison operators matter more for data science starters.
Quick check: Bitwise Operators
Question 1 of 2
Bitwise operators work on: