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)
  1. A. False True
  2. B. True False
  3. C. True True
  4. 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

Exams that ask this topic