ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(0.1 + 0.2 in [0.3], 0.3 in [0.1 + 0.2], round(0.1 + 0.2, 1) in [0.3])
  1. A. True True False
  2. B. False False True
  3. C. False True True
  4. D. False False False

Correct answer: B. False False True

0.1 + 0.2 is not equal to 0.3 as a float, so both exact membership tests fail. Rounding to one place gives the float 0.3, which is in the list.

More Python Programming questions

Exams that ask this topic