ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print([1, 2] < [1, 2, 0], [1, 2] < [1, 3, 0], (1, 2) < (1, 2, 0), 'ab' < 'abc')
  1. A. True True False True
  2. B. True False True True
  3. C. False True True True
  4. D. True True True True

Correct answer: D. True True True True

Sequences compare element by element, and when one is a prefix of the other the longer one is greater. The second list wins at the second element because 2 < 3.

More Python Programming questions

Exams that ask this topic