ProgrammingVery hardGATE CS · Product-company placement

What is printed?

What is printed?
import sys
print(sys.float_info.epsilon, 1.0 + sys.float_info.epsilon > 1.0, 1.0 + sys.float_info.epsilon / 2 > 1.0)
  1. A. 2.220446049250313e-16 True True
  2. B. 1.1102230246251565e-16 True False
  3. C. 2.220446049250313e-16 True False
  4. D. 2.220446049250313e-16 False False

Correct answer: C. 2.220446049250313e-16 True False

epsilon is the gap between 1.0 and the next double. Half of epsilon is a tie that rounds back to 1.0 under round-half-to-even, so adding it changes nothing.

More Python Programming questions

Exams that ask this topic