Report Bug
Qus : What will the following code output? print(2 << 2)
Qusनिम्नलिखित कोड आउटपुट क्या होगा? print(2 << 2)

A. 4
B. 8
C. 16
D. 32


Solution
B. 8



Explanation

The << operator in Python (and many other languages, including JavaScript) is the bitwise left shift operator. It shifts the bits of the first operand to the left by the number of positions specified by the second operand.


Step-by-Step Process:

Binary Representation of 2:

The number 2 in binary is 10.


Shift Bits to the Left by 2:

Shifting 10 to the left by 2 positions adds two zeros to the right:




Report Bug