CBSE Class 11 Computer Science Question 44 of 82

Lists in Python — Question 9

Back to all questions
9
Question

Question 8(b)

What will be the output of the following statement?

list1 = [12, 32, 65, 26, 80, 10]
sorted(list1)
print(list1)
Answer
Output
[12, 32, 65, 26, 80, 10]
Explanation

In the given code, list1 is initialized as [12, 32, 65, 26, 80, 10]. The sorted(list1) function is called, which creates and returns a new list with the elements of list1 sorted in ascending order, but it does not modify the original list1. Since the sorted result is not stored or printed, the next line print(list1) outputs the original unsorted list [12, 32, 65, 26, 80, 10].