ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(0.1 + 0.2 > 0.3, 0.5 + 0.25 == 0.75, 1 / 3 * 3 == 1.0)
  1. A. True True False
  2. B. True True True
  3. C. False True True
  4. D. True False True

Correct answer: B. True True True

0.1 + 0.2 is slightly greater than 0.3 in floating point. 0.5 and 0.25 are exact in binary, so their sum is exact. 1/3 rounds down, but times 3 it rounds back to exactly 1.0.

More Python Programming questions

Exams that ask this topic