आइए मान लें कि 4 बाइनरी में 100 है और 11 1011 है। निम्नलिखित बिटवाइज़ का आउटपुट संचालक क्या है?
Let us assume 4 is 100 in binary and 11 is 1011. What is the output of the following bitwise operators ?
a = 4
b = 11
print(a | b)
print(a >> 2) A
15 1
B
14 1
C
17 2
D
16 2
Explanation
Let's go through it briefly:
-
Bitwise OR (
|):a = 4(binary:100),b = 11(binary:1011)- OR operation gives
1111in binary, which equals 15 in decimal.
-
Right Shift (
>>):a = 4(binary:100)- Shifting right by 2 positions:
100becomes1, which equals 1 in decimal.
Final Output:
(A) 15 1
Correct Answer: A) 15 1