ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(0.1 + 0.1 + 0.1 == 0.3, 0.1 + 0.1 + 0.1, 0.3 == 3 * 0.1)
  1. A. True 0.3 True
  2. B. False 0.3 False
  3. C. False 0.30000000000000004 True
  4. D. False 0.30000000000000004 False

Correct answer: D. False 0.30000000000000004 False

Adding 0.1 three times gives 0.30000000000000004, which is not the double nearest 0.3. Multiplying 0.1 by 3 gives the same wrong value, so both comparisons are False.

More Python Programming questions

Exams that ask this topic