ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(0.1 * 10 == 1.0, 0.1 * 10, sum([0.1] * 10) == 1)
  1. A. False 1.0 True
  2. B. True 1.0 True
  3. C. True 0.9999999999999999 True
  4. D. True 1.0 False

Correct answer: B. True 1.0 True

0.1 * 10 rounds to exactly 1.0 in one multiplication. sum() uses compensated summation since Python 3.12, so the ten additions also land on 1.0.

More Python Programming questions

Exams that ask this topic