ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(f'{1234567.891:_.2f}', f'{255:#x}', f'{5:03d}', f'{-5:03d}', f'{-5:+04d}')- A. 1_234_567.89 0xff 005 -05 -005
- B. 1_234_567.9 0xff 005 -05 -005
- C. 1_234_567.89 0o377 005 -05 -005
- D. 1_234_567.89 0xff 5 -05 -005
Correct answer: A. 1_234_567.89 0xff 005 -05 -005
The _ flag groups thousands with underscores, and the # flag adds the 0x prefix. Zero-padding with width 3 counts the minus sign, so -5 becomes -05 and the + variant gives -005.
More Python Programming questions
- What is printed? python print(str(-0), int('-0'), -0.0 == 0, str(-0.0), 0 -1.0)
- What is printed? python print(str(1e21), str(1e15), str(123456789.123), 1e21 == 1021, float(1021) == 1e21)
- What is printed? python print(str(1e-5), 0.0001, 0.00001, 1e-4 == 0.0001, 10 -4)
- What is printed? python print(sorted(['10', '9', '2b', '2a']), sorted([10, 9, 2], key=str))
- What is printed on the last line? python try: sorted([1, '2']) except TypeError: print('TypeError') print(sorted([1, '2'], key=str))
- What is printed? python print(max([], default=-1), min([3], default=0), sum([]), sum([], 0.0), any([]) or all([]))