ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(1e-7 == 0.0000001, 1e-7, 0.0000001, 1.0e5 == 100000.0, 123e-2)
- A. True 1e-07 1e-07 True 1.23
- B. True 0.0000001 0.0000001 True 1.23
- C. False 1e-07 1e-07 True 1.23
- D. True 1e-07 1e-07 True 0.0123
Correct answer: A. True 1e-07 1e-07 True 1.23
Floats below 1e-4 print in scientific notation, and the exponent has at least two digits, so 1e-07. The two literals name the same double, so they compare equal.
More Python Programming questions
- What is printed? python print(7 // 2 2 + 7 % 2 == 7, -(7 // 2) 2 + -(7 % 2) == -7, (-7) // 2 2 + (-7) % 2)
- What is printed? python print(int('12' '34') + 1, '%d' % 3.9, '%i' % -3.9, '%+d' % 0)
- Which approach removes duplicates from a list while keeping the first-seen order, in O(n) average time?
- Which statement about sorting 10^6 floats with sorted() in CPython is correct?
- Which operation is O(1) amortised in CPython?
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def f(a, b=0): return a + b f(1, 2) f(1, b=2) f(1)…