ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
inf = float('inf')
print(inf > 10**400, inf - inf == 0, -inf < -10**400, inf == inf)
  1. A. True True True True
  2. B. True False True True
  3. C. False False True True
  4. D. True False False True

Correct answer: B. True False True True

Comparisons between floats and huge ints work in Python, so inf is greater than 10**400. inf - inf is NaN, which is not equal to 0, and -inf is below any finite number, while inf == inf holds.

More Python Programming questions

Exams that ask this topic