ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('x' * 0 == '', 'Z' < 'a', '10' < '9', 'apple' < 'Apple')
  1. A. True False True True
  2. B. True True True True
  3. C. True True True False
  4. D. True True False False

Correct answer: C. True True True False

Strings compare by code point, so 'Z' (90) is less than 'a' (97) and '10' is less than '9' because '1' comes before '9'. Lowercase 'a' (97) is greater than capital 'A' (65), so 'apple' is not less than 'Apple'.

More Python Programming questions

Exams that ask this topic