ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(0.1 * 0.1 == 0.01, round(0.1 * 0.1, 2) == 0.01)
- A. False True
- B. True False
- C. True True
- D. False False
Correct answer: A. False True
0.1 * 0.1 is 0.010000000000000002 in floating point, so the first comparison is False. Rounding to two places gives the double nearest to 0.01, so the second is True.
More Python Programming questions
- What is printed? python print(list(filter(None, [0, 1, '', 'a', None, [], [0]])))
- What is printed? python x = 5 print(x.add(3), (5).bitlength(), 5 .real)
- What is printed? python print({{'a': 1, 'b': 2}, 'a': 3})
- What is printed? python a, b, c = [1, 2, 3, 4] print(a, b, c)
- What is printed? python print(12 & -12, 12 & 11, ~12 & 0xF)
- Which loop builds a list of n items in total O(n^2) time in CPython, because each step copies the whole list?