ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(max([1, 2], [1, 2, 0]) == [1, 2, 0], min((1, 'a'), (1, 'b')), sorted([(1, 'b'), (1, 'a')])[0][1])
  1. A. False (1, 'b') b
  2. B. True (1, 'a') a
  3. C. True (1, 'b') a
  4. D. True (1, 'a') b

Correct answer: B. True (1, 'a') a

Lists compare element by element, and [1, 2, 0] is longer than [1, 2], so it is the maximum. Tuples compare the second item when the first items tie, so (1, 'a') is the smallest.

More Python Programming questions

Exams that ask this topic