ProgrammingVery hardJEE Main · CAT placement

What is printed?

What is printed?
x = 0b1011
print(x & ~(1 << 1), x ^ (1 << 2), x | (1 << 4), (x >> 1) & 1)
  1. A. 9 15 27 1
  2. B. 11 15 27 1
  3. C. 9 7 27 1
  4. D. 9 15 27 0

Correct answer: A. 9 15 27 1

~(1 << 1) clears bit 1, so 1011 becomes 1001 = 9. XOR with bit 2 sets it to 1111 = 15, OR with bit 4 gives 27, and bit 1 of x after shifting is 1.

More Python Programming questions

Exams that ask this topic