ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(bin(255)[2:].rjust(10, '0'), int('0b' + '1' * 8, 2) == 255, int('11111111', 2) + 0 == 255)
  1. A. 11111111 True True
  2. B. 0011111111 False True
  3. C. 0011111111 True False
  4. D. 0011111111 True True

Correct answer: D. 0011111111 True True

rjust pads on the left to width 10 with zeros, and int accepts a 0b prefix when the base is 2. Both int conversions give 255.

More Python Programming questions

Exams that ask this topic