ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
nan = float("nan")
print(max(nan, 1), max(1, nan), min(nan, 1), nan in {nan})
  1. A. nan nan nan False
  2. B. 1 1 1 True
  3. C. nan 1 nan True
  4. D. nan 1 1 False

Correct answer: C. nan 1 nan True

max/min keep the first item and replace it only when a later item compares greater (or smaller); every comparison with NaN is False, so the result depends on argument order. Set membership checks identity first, so the same nan object is found.

More Python Programming questions

Exams that ask this topic