ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(hash(()) == hash(()), (1, 2) < (1, 2, 0), 'b' * 2 > 'ab' * 2, (1, 'b') < (1, 'a'))
  1. A. False True True True
  2. B. True False True False
  3. C. True True False False
  4. D. True True True False

Correct answer: D. True True True False

Equal tuples hash equally, and a prefix of a tuple is smaller than the longer tuple. bb is greater than abab because b is greater than a at the first position. (1, 'b') is not less than (1, 'a').

More Python Programming questions

Exams that ask this topic