Learn Before
Concept

Bitwise Operators in Python

In Python, bitwise operators allow the direct manipulation of individual bits (1s and 0s) within a bit string. The primary bitwise operators in Python include:

  • Bitwise AND (&): Compares two bit strings and returns a new bit string with 1s only where both corresponding bits are 1.
  • Bitwise OR (|): Compares two bit strings and returns a new bit string with 1s where at least one corresponding bit is 1.
  • Bitwise Left Shift (<<): Shifts the bits of the first operand to the left by the number of positions specified by the second operand.
  • Bitwise Right Shift (>>): Shifts the bits of the first operand to the right by the number of positions specified by the second operand.

0

1

Updated 2026-07-07

Tags

Python Programming Language

Data Science

Learn After