QuestenaPractice that shows what to review next
Question 11

Why can a calculation with the float `0.1` show a tiny discrepancy from the expected decimal result?

  1. Python randomly changes the final decimal digit.
  2. Binary float cannot represent every decimal fraction exactly.Correct answer
  3. A float always performs integer division before storage.
  4. The value is exact, so any discrepancy must be a display bug.

Explanation

A binary floating-point value usually stores the closest representable approximation to one tenth rather than that decimal fraction exactly. The discrepancy is therefore a representation effect, not evidence that integer division secretly occurred.

Continue with this test

Start practice
Question 11: Why can a calculation with the float `0.1` show a tiny… · Python Fundamentals · Questena