ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(1 / 3 + 1 / 3 + 1 / 3 == 1.0, 0.1 + 0.7)
  1. A. False 0.8
  2. B. True 0.7999999999999999
  3. C. False 0.7999999999999999
  4. D. True 0.8

Correct answer: B. True 0.7999999999999999

Three thirds add up to exactly 1.0 in floating point here. 0.1 + 0.7 is 0.7999999999999999 because neither operand is exact.

More Python Programming questions

Exams that ask this topic