5 pts D Question 48 Wite a Python program that can perform the following operati
ID: 3723851 • Letter: 5
Question
5 pts D Question 48 Wite a Python program that can perform the following operations on list (1) Create a list thut contains the elements below 145, 67,34, 89,31, 521 2) Insert number 76 to the middle of the list (between 34 and 89) with the insert method insertlindex, item). Print the updated list (3) Sort the ist in ascending order with the sort method sortO. Print the updated list (4) Remove the number 89 from the list with the remove method removelitem). Print the updated list. 5) Reverse the order of elements in the list with the reverse method reversed. Print the updated list. 6) Delete the first element of the list with the del statement print the updated ist number and maximum number stored in the list. with the min function and max function. Print these two original list: [45, 67, 34, 89, 31, 521 List after insertion: [45, 67, 34, 76, 89 , 31, 52] ist after sorting: 131, 34. 45, 52, 67, 76, 891 List after removal: [31, 34, 45, 52, 67, 76] List after reversing: List after deletion: (67, 52, 45, 34 Minimum element: 31 Maximum element: 67 [76, 67, 52, 45, 34, 31] , 31]Explanation / Answer
I have performed all your functions Please have a look at the code.I have added proper comments so the code is self-explanatory
Code:
Output:
Original list: [45, 67, 34, 89, 31, 52]
List after Insertion: [45, 67, 34, 76, 89, 31, 52]
List after Sorting: [31, 34, 45, 52, 67, 76, 89]
List after Removal: [31, 34, 45, 52, 67, 76]
List after reversing: [76, 67, 52, 45, 34, 31]
List after deletion: [67, 52, 45, 34, 31]
minimum element: 31 maximum element: 67
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.