ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print(5 // 0.4, 5 % 0.4, 0.4 * 12 == 4.8, 5 / 0.4)
  1. A. 12.0 0.2 False 12.5
  2. B. 12.0 0.19999999999999973 False 12.5
  3. C. 12.0 0.19999999999999973 True 12.5
  4. D. 11.0 0.19999999999999973 False 12.5

Correct answer: B. 12.0 0.19999999999999973 False 12.5

0.4 is stored slightly above the decimal value, so 5 // 0.4 is 12.0 and the remainder is a little under 0.2. Multiplying 0.4 by 12 misses 4.8 exactly.

More Python Programming questions

Exams that ask this topic