Learn Before
Concept
Bitwise Operators in Python
Every piece of information on the computer is stored as a string of 1's and 0's, otherwise known as a bit string. Bitwise operators, which are similar across most programming languages, allow you to manipulate those bit strings directly. Some bitwise operators are:
- bitwise AND: compares two bit strings and returns a new bit string with bits in the places where both bit strings have a bit, denoted by &
- bitwise OR: compares two bit strings and returns a new bit string with bits in the places that at least one bit string has a bit in, denoted by |
- bitwise left shift: takes two operands and shifts the bits of the first operand's bit string left by the number of places specified by the value of the second operand, denoted by <<
- bitwise right shift: takes two operands and shifts the bits of the first operand's bit string right by the number of places specified by the value of the second operand, denoted by >>
0
1
Updated 2025-06-24
Tags
Python Programming Language
Data Science