ProgrammingHardTCS NQT · Infosys

What is printed?

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

Correct answer: B. True True True False False

Strings compare by code point, so 'Z' (90) sorts before 'a' (97), and '10' sorts before '9' because '1' comes before '9'. Lists and tuples compare element by element, so [10] < [9] is False, and (1, 'b') < (1, 'a') is False.

More Python Programming questions

Exams that ask this topic