Sorting · Class 12 · CBSE · Science Computer Science

Which statement correctly describes the difference between list.sort() and sorted() in Python?

Practice question from Sorting (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-2625C0

Which statement correctly describes the difference between list.sort() and sorted() in Python?

  1. A.list.sort() returns a new sorted list, while sorted() changes the original list.
  2. B.list.sort() changes the original list, while sorted() returns a new sorted list.Correct answer
  3. C.Both list.sort() and sorted() always change the original list.
  4. D.Neither list.sort() nor sorted() can arrange a list in descending order.

Solution

The sort() method modifies the list on which it is called and returns None. The sorted() function leaves the original iterable unchanged and returns a new sorted list; both support reverse=True for descending order.

More from Sorting

All of Sorting

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed