ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(float('%.2f' % 0.125), '%.3e' % 12345.678)- A. 0.13 1.235e+04
- B. 0.12 1.234e+04
- C. 0.125 1.235e+04
- D. 0.12 1.235e+04
Correct answer: D. 0.12 1.235e+04
0.125 is exact in binary, so the tie goes to the even last digit, which gives 0.12. 12345.678 rounded to three decimal places in scientific form is 1.235e+04.
More Python Programming questions
- What is printed? python print(int(str(2 70)[:5]), len(str(2 70)))
- What is printed? python print(list(range(10, 0, -4)), [sum(r) for r in [(1, 2), (3,)]])
- What is printed? python print(2 0.5 2 0.5, 2 0.5 2 0.5 == 2.0, round(2 0.5 2 0.5))
- What is printed? python print(min(map(str, [10, 9, 100])), sorted(['10', '9', '100']), sorted([10, 9, 100]))
- What is printed? python print(len([x for x in range(10) if x % 3 == 0]), sum(range(0, 10, 3)))
- What is printed? python x = [3, 1, 2] y = sorted(x) x.sort(reverse=True) print(x, y, x is y)