What will be the output of the following statements?
list1 = [12,32,65,26,80,10] list1.sort() print(list1)
[10, 12, 26, 32, 65, 80]
list1 = [12,32,65,26,80,10] sorted(list1) print(list1)
[12, 32, 65, 26, 80, 10]
list1 = [1,2,3,4,5,6,7,8,9,10] list1[:-2] list1[:3] + list1[3:]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list1 = [1,2,3,4,5] list1[len(list1)-1]
5
Explanation
For part (i), the sort() function modifies the list in-place because lists are mutable, arranging elements in ascending order. In part (ii), sorted() returns a new sorted list but does not change the original list object; since the return value isn't stored, printing list1 shows the original unsorted list. For part (iii), list1[:3] extracts the first three elements and list1[3:] extracts elements from index 3 to the end; the + operator concatenates them back into the original sequence. In part (iv), len(list1) is 5, so the index accessed is 4, which refers to the last element.