ProgrammingHardGATE CS & IT · Infosys

What is printed?

What is printed?
print(bin(5 ^ 3), int('101', 2) << 2, ~5, -~5)
  1. A. 0b110 20 -5 5
  2. B. 0b101 20 -6 6
  3. C. 0b110 5 -6 6
  4. D. 0b110 20 -6 6

Correct answer: D. 0b110 20 -6 6

5 ^ 3 is 6, which prints as 0b110. ~5 is -6, and -~5 is -(-6) = 6. Shifting 5 left by two gives 20.

More Python Programming questions

Exams that ask this topic