ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
x = 255
print(f'{x:x}', f'{x:08b}', f'{x:o}', f'{x:#06x}')
  1. A. ff 11111111 377 0x00ff
  2. B. ff 11111111 377 0x00ee
  3. C. ff 11111111 377 0xff
  4. D. ff 255 377 0x00ff

Correct answer: A. ff 11111111 377 0x00ff

x in hex is ff and 08b pads the binary to eight digits. Octal 255 is 377. The # flag adds the 0x prefix, and 06 pads the whole string including the prefix to six characters.

More Python Programming questions

Exams that ask this topic