ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print('%.3f' % 1.0005, '%.1f' % 0.25, '%.1f' % 0.35, round(0.35, 1))- A. 1.001 0.2 0.3 0.3
- B. 1.000 0.3 0.3 0.3
- C. 1.000 0.2 0.3 0.3
- D. 1.000 0.2 0.4 0.4
Correct answer: C. 1.000 0.2 0.3 0.3
1.0005 is stored a little below the midpoint, so it rounds down. 0.25 is exact and ties to even giving 0.2, while 0.35 is stored just below its midpoint and gives 0.3.
More Python Programming questions
- What is printed? python from collections import Counter c = Counter('mississippi') print(c.mostcommon(2), sorted(c.items(), key=lambda kv…
- What is printed? python x = 5 y = x if x > 3 else 0 + 1 if x else -1 print(y, (lambda a, b=2: a b)(3), (lambda a: sum(a))(1, 2, 3))
- What is printed? python print(sorted([2.0, 2, True, 1.5]))
- What is printed? python print(len({1: 'a', True: 'b', 1.0: 'c'}), list({True: 1, 1: 2}.keys()))
- What is printed? python print(int(1e308) > 10308, float('1e-400'), 5e-324 / 2, 5e-324 / 2 == 0)
- What is printed? python print(1e-7 == 0.0000001, 1e-7, 0.0000001, 1.0e5 == 100000.0, 123e-2)