Report Bug

QusWhat 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:

Latest Current Affairs 2026 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad