ProgrammingHardCognizant GenC · TCS NQT

What is printed?

What is printed?
print([3, 1].sort() or 'x', sorted([3, 1]) == [1, 3])
  1. A. None True
  2. B. x False
  3. C. [1, 3] True
  4. D. x True

Correct answer: D. x True

list.sort returns None, which is falsy, so the or expression gives 'x'. sorted returns a new list [1, 3], so the comparison is True.

More Python Programming questions

Exams that ask this topic