ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(f'{12345678:,}', f'{0.5:.0%}', f'{2.5:.0f}', f'{3.5:.0f}', f'{-0.4:.0f}')- A. 12,345,678 50% 3 4 -0
- B. 12345678 50% 2 4 -0
- C. 12,345,678 50% 2 4 -1
- D. 12,345,678 50% 2 4 -0
Correct answer: D. 12,345,678 50% 2 4 -0
Format rounding is round-half-to-even, so 2.5 becomes 2 and 3.5 becomes 4. -0.4 rounds to zero but keeps its sign, so the output is -0.
More Python Programming questions
- What is printed? python print(repr(1e16), repr(1e15 + 0.3), 1e16 == 1016, 1e16 + 1 == 1e16)
- What is printed? python print(10 -2, 10.0 -2, 1000 10, 2 -1 4)
- What is printed? python print(bool(0.0), bool(-0.0), bool(float('nan')), bool(' '), bool('0'), bool(0j))
- What is printed? python s1 = 'u00e9' s2 = 'eu0301' print(s1 == s2, len(s1), len(s2), len(s2.encode()), s2 == 'eu0301')
- What is printed? python print(len('héllo'.encode('utf-8')), len('héllo'.encode('utf-16')), len('héllo'))
- What is printed? python print('abc' < 'abd', 'Z' < 'a', '10' < '9', [10] < [9], (1, 'b') < (1, 'a'))