ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
print(min([], default=0), max([2, 7], default=0), min("b", "a", key=ord), sum([[1], [2]], []))
  1. A. 0 7 a [1, 2]
  2. B. ValueError
  3. C. 0 7 b [1, 2]
  4. D. 0 7 a TypeError

Correct answer: A. 0 7 a [1, 2]

default is returned only for an empty iterable. key=ord makes min compare code points, so 'a' wins. sum with a start value of [] concatenates the lists (slow, but legal; only str is refused by sum).

More Python Programming questions

Exams that ask this topic