ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('a' * 3 < 'b', 'a' * 3 < 'aa', 'aaa' > 'aab', 'aa' + 'b' > 'aab')
  1. A. True False False False
  2. B. True True False False
  3. C. False False True False
  4. D. True False True False

Correct answer: A. True False False False

Strings compare character by character, so aaa is less than b. aaa is less than aa only if it is shorter, which it is not, and aaa is less than aab because its third character is smaller.

More Python Programming questions

Exams that ask this topic