Question DSA-SORT-0006
EasyWhat is the output of this code?
print(sorted([5, 2, 8, 1, 9]))
- A.
[5, 2, 8, 1, 9]
- B.
[1, 5, 2, 8, 9]
- C.
Show answer and explanation
Answer: C
sorted() returns a new list in ascending order.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Sorting question
What is the output of this code?
print(sorted([5, 2, 8, 1, 9]))
[5, 2, 8, 1, 9]
[1, 5, 2, 8, 9]
Answer: C
sorted() returns a new list in ascending order.
[1, 2, 5, 8, 9]
[9, 8, 5, 2, 1]