ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(bin(10 ^ 6), 10 ^ 6 ^ 6, 3 ^ 5 ^ 3 ^ 5, ~-1, -~1)
  1. A. 0b1100 10 0 1 2
  2. B. 0b1100 10 0 0 2
  3. C. 0b1010 10 0 0 2
  4. D. 0b1100 12 0 -1 2

Correct answer: B. 0b1100 10 0 0 2

10 ^ 6 is 12 (0b1100). XOR with the same value twice cancels, so 10 ^ 6 ^ 6 is 10. ~-1 is 0, and -~1 is -(-2) = 2.

More Python Programming questions

Exams that ask this topic