Computer Science, asked by Yashgupta4421, 9 months ago

Write source code in Python to explain bitwise operators.

Answers

Answered by Anonymous
0

Answer:

Python Bitwise Operators

Python Bitwise operators help perform bit operations. All the decimal values will convert into binary values (bits sequence i.e., 0100, 1100, 1000, 1001, etc.). Next, Python bitwise operators work on these bits, such as shifting left to right or transforming bit value from 0 to 1, etc.

Answered by SteffiPaul
0

Source code explaining bitwise operators in Python is given as -

  • Operator     Description                   Example
  • &             Bitwise AND            X & Y = 0000
  1. 0 & 0 0
  2. 0 & 1 0
  3. 1 & 0 0
  4. 1 & 1          1
  • |             Bitwise OR                    X | Y = 1110
  1. 0|0 0
  2. 0|1 1
  3. 1|0 1
  4. 1|1 1
  • ^             Bitwise exclusive OR    X ^ Y = 1110
  1. 0^0 0
  2. 0^1 1
  3. 1^0 1
  4. 1^1 0
  • ~             Bitwise complement    ~X = 00001001 (Bitwise Not operator will convert all 0 into 1.)

Similar questions