ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
x = 255
print(f'{x:08b}', f'{x:o}', f'{x:X}', f'{x:#010x}')
  1. A. 11111111 777 FF 0x000000ff
  2. B. 11111111 377 FE 0x000000ff
  3. C. 11111111 377 FF 0x0000ff00
  4. D. 11111111 377 FF 0x000000ff

Correct answer: D. 11111111 377 FF 0x000000ff

255 is eight ones in binary and 377 in octal. The # flag with width 10 pads the hex form with zeros after the 0x prefix.

More Python Programming questions

Exams that ask this topic