ProgrammingVery hardCapgemini · Python · Advanced

What is printed?

What is printed?
print(f"{255:#x} {255:08b} {3.14159:.2f} {'ab':>4}|{12345.678:,.1f}")
  1. A. 0xff 11111111 3.14 ab |12,345.7
  2. B. 0xff 11111111 3.14 ab|12,345.7
  3. C. 0xff 0b11111111 3.14 ab|12,345.7
  4. D. 0xff 11111111 3.14 ab|12345.7

Correct answer: B. 0xff 11111111 3.14 ab|12,345.7

#x adds the 0x prefix; 08b is zero-padded binary without a prefix; >4 right-aligns; ',.1f' adds a thousands separator and rounds to one decimal.

More Python Programming questions

Exams that ask this topic