ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print('{0:.2%}'.format(0.12345), '{:,}'.format(1234), '{:e}'.format(0), '{:.0f}'.format(0.5))- A. 12.34% 1,234 0.000000e+00 0
- B. 12.35% 1234 0.000000e+00 0
- C. 12.35% 1,234 0.000000e+00 1
- D. 12.35% 1,234 0.000000e+00 0
Correct answer: D. 12.35% 1,234 0.000000e+00 0
0.12345 is stored a little above the midpoint, so two decimal places of the percentage round up to 12.35%. The .0f format uses round-half-to-even, so 0.5 becomes 0.
More Python Programming questions
- What is printed? python print(0.1 + 0.2 == 0.3 or 'no', 0.5 + 0.25 == 0.75 and 'yes')
- What is printed? python print(divmod(-7, 3), divmod(7, -3), divmod(-8.5, 4))
- What is printed? python print(abs(-7) // 2 -1, -abs(-7) // 2, -(abs(-7) // 2))
- What is printed? python x = 255 print(f'{x:08b}', f'{x:o}', f'{x:X}', f'{x:#010x}')
- 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))