Write source code in Python to explain bitwise operators.
Answers
Answered by
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
0
Source code explaining bitwise operators in Python is given as -
- Operator Description Example
- & Bitwise AND X & Y = 0000
- 0 & 0 0
- 0 & 1 0
- 1 & 0 0
- 1 & 1 1
- | Bitwise OR X | Y = 1110
- 0|0 0
- 0|1 1
- 1|0 1
- 1|1 1
- ^ Bitwise exclusive OR X ^ Y = 1110
- 0^0 0
- 0^1 1
- 1^0 1
- 1^1 0
- ~ Bitwise complement ~X = 00001001 (Bitwise Not operator will convert all 0 into 1.)
Similar questions
Math,
5 months ago
Science,
5 months ago
Social Sciences,
5 months ago
Computer Science,
11 months ago
Math,
11 months ago