ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
x = 0b1010
y = 0o17
z = 0xFF
print(x ^ y, x | z, z >> 4, y & ~x)
  1. A. 5 127 15 5
  2. B. 5 255 15 15
  3. C. 5 255 15 5
  4. D. 21 255 15 5

Correct answer: C. 5 255 15 5

1010 XOR 1111 is 0101, which is 5. 1010 OR 11111111 is 255. 0xFF >> 4 is 15. ~10 is -11, and 15 & -11 keeps the low four bits 0101, which is 5.

More Python Programming questions

Exams that ask this topic