ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: B. True True True False

A shorter sequence that is a prefix of a longer one compares as smaller for both lists and tuples. Strings compare by code point, and [2] < [1, 9] is decided by the first elements, 2 < 1, which is False.

More Python Programming questions

Exams that ask this topic