ExamVeda
Login
Home
Python Built In Functions
?

What is the output of the following code:
my_list = [3, 1, 4, 1]
print(sorted(my_list))

Answer & Solution
Correct Answer: Option A
The correct answer is Option A: [1, 1, 3, 4].
The sorted() function in Python is used to sort the elements of an iterable in ascending order. When you pass the list [3, 1, 4, 1] to the sorted() function, it sorts the elements and returns a new list with the elements sorted in ascending order. Therefore, the output will be [1, 1, 3, 4].
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.