ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print('%.2e' % 0, '%.1f' % 2.25, '%.1f' % 2.35, '%5.1f|' % -0.04)- A. 0.00e+00 2.2 2.4 -0.0|
- B. 0.00e+00 2.3 2.4 -0.0|
- C. 0.00e+00 2.2 2.3 -0.0|
- D. 0.00e+00 2.2 2.4 -0.00|
Correct answer: A. 0.00e+00 2.2 2.4 -0.0|
2.25 is exactly halfway, so %.1f rounds it to the even 2.2. 2.35 is stored slightly above the midpoint and rounds to 2.4. The width of 5 pads -0.0 with one space on the left.
More Python Programming questions
- What is printed? python x = 0.1 print((0.5).asintegerratio(), (0.1).asintegerratio()[1] == 255)
- What is printed? python import operator print(operator.index(5), operator.mod(-7, 3), operator.floordiv(-7, 3))
- What is printed? python print(sorted(['b', 'B', 'a', 'A'], key=lambda s: s.swapcase()))
- What is printed? python print(len(set('mississippi')), sorted(set('mississippi')))
- What is printed? python print(7 -1 == 1 / 7, pow(7, -1, 13) 7 % 13, (7 2) % 13, 2 3 2 % 10)
- What is printed? python x = [0] 3 x[0] += 1 y = [[0]] 2 y[0][0] += 1 print(x, y)