ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(sorted([0.5, 1, True, False]), max(0.5, 1, True))
  1. A. [False, 0.5, True, 1] True
  2. B. [False, 0.5, 1, True] 1
  3. C. [False, 0.5, 1, True] True
  4. D. [0.5, False, 1, True] 1

Correct answer: B. [False, 0.5, 1, True] 1

False is 0 and is the smallest. 1 and True compare equal, so sorted keeps their input order, and max returns the first of equal maxima, which is 1.

More Python Programming questions

Exams that ask this topic