ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
x = 255
print(f'{x:08b}', f'{x:o}', f'{x:X}', f'{x:#010x}')- A. 11111111 777 FF 0x000000ff
- B. 11111111 377 FE 0x000000ff
- C. 11111111 377 FF 0x0000ff00
- 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
- What is printed? python print(int('11', 2) + int('11', 8) + int('11', 16))
- What is printed? python print(round(1234.5678, -2), round(-1234.5678, 2), round(0.000123456, 5))
- What is printed? python print(7 / 7, 0 / 5, -0 / 5, 2 0, 0 0.0)
- What is printed? python print(7 // 1.0 1, 1e3 // 7, -1e3 // 7, 10 % -3.0)
- What is printed? python print(bool(''), bool('False'), bool([]), bool([[]]), bool(None))
- What is printed? python print(str(3) + str(3.0), 3 + 3.0, '3' 3 == '333')