TASK 4: Python Lists

1.Create a list of five delivery items and print the third item in the list. eg: [“Notebook”, “Pencil”, “Eraser”, “Ruler”, “Marker”] 2.A new delivery item “Glue Stick” needs to be added to the list. Add it to the end of the list and print the updated list. 3.Insert “Highlighter” between the second and third items and print the updated list. 4.One delivery was canceled. Remove “Ruler” from the list and print the updated list. 5.The delivery man needs to deliver only the first three items. Print a sublist containing only these items. 6.The delivery man has finished his deliveries. Convert all item names to uppercase using a list comprehension and print the new list. 7.Check if “Marker” is still in the list and print a message indicating whether it is found. 8.Print the number of delivery items in the list. 9.Sort the list of items in alphabetical order and print the sorted list. 10.The delivery man decides to reverse the order of his deliveries. Reverse the list and print it. 11.Create a list where each item is a list containing a delivery item and its delivery time. Print the first item and its time. 12.Count how many times “Ruler” appears in the list and print the count. 13.Find the index of “Pencil” in the list and print it. 14.Extend the list items with another list of new delivery items and print the updated list. 15.Clear the list of all delivery items and print the list. 16.Create a list with the item “Notebook” repeated three times and print the list. 17.Using a nested list comprehension, create a list of lists where each sublist contains an item and its length, then print the new list. 18.Filter the list to include only items that contain the letter “e” and print the filtered list. 19.Remove duplicate items from the list and print the list of unique items.

Apr 26, 2025 - 03:43
 0
TASK 4: Python Lists

1.Create a list of five delivery items and print the third item in the list. eg: [“Notebook”, “Pencil”, “Eraser”, “Ruler”, “Marker”]
2.A new delivery item “Glue Stick” needs to be added to the list. Add it to the end of the list and print the updated list.
3.Insert “Highlighter” between the second and third items and print the updated list.
4.One delivery was canceled. Remove “Ruler” from the list and print the updated list.
5.The delivery man needs to deliver only the first three items. Print a sublist containing only these items.
6.The delivery man has finished his deliveries. Convert all item names to uppercase using a list comprehension and print the new list.
7.Check if “Marker” is still in the list and print a message indicating whether it is found.
8.Print the number of delivery items in the list.
9.Sort the list of items in alphabetical order and print the sorted list.
10.The delivery man decides to reverse the order of his deliveries. Reverse the list and print it.
11.Create a list where each item is a list containing a delivery item and its delivery time. Print the first item and its time.
12.Count how many times “Ruler” appears in the list and print the count.
13.Find the index of “Pencil” in the list and print it.
14.Extend the list items with another list of new delivery items and print the updated list.
15.Clear the list of all delivery items and print the list.
16.Create a list with the item “Notebook” repeated three times and print the list.
17.Using a nested list comprehension, create a list of lists where each sublist contains an item and its length, then print the new list.
18.Filter the list to include only items that contain the letter “e” and print the filtered list.
19.Remove duplicate items from the list and print the list of unique items.