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 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz