ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(max(3, 3.0), max(3.0, 3), min(-0.0, 0), min(0, -0.0))
  1. A. 3 3.0 0.0 -0.0
  2. B. 3 3.0 -0.0 0
  3. C. 3.0 3 -0.0 0
  4. D. 3 3 -0.0 1

Correct answer: B. 3 3.0 -0.0 0

max and min return the first of equal values, so max(3, 3.0) is 3 and max(3.0, 3) is 3.0. min(-0.0, 0) returns -0.0 because the two compare equal and the first is kept.

More Python Programming questions

Exams that ask this topic