Basic Python Programming (313011) Practical No.6 Write Python program to perform following operations on List: a) Create b) Access c) Update d) Delete elements from list
Lists in Python are crucial for storing and managing ordered collections of items, providing flexibility with various data types. They support dynamic sizing, allowing for efficient addition and removal of elements. Lists are integral to data processing tasks such as sorting, filtering, and iterating over elements. Their versatility and built-in methods enhance code readability and efficiency in handling complex data operations.
Practical related questions
1) Write a Python program that takes a list of numbers as input and prints the sum of all the elements in the list.
Answer:
2) Create a Python program that filters out even numbers from a list of integers and prints the filtered list.
Answer:
3) Write a Python program that reverses a given list of characters and prints the reversed list.
Answer:
4) Write a Python program that duplicates a given list of strings and prints the duplicated list.
Answer:
5) Develop a Python program that takes a list of strings as input and prints the length of the longest string in the list.
Answer:
Exercise
1) Create a Python program that sorts a list of strings in ascending order and prints the sorted list.
Answer:
2) Write a Python program that takes two lists as input and concatenates them into a single list. Then, print the concatenated list.
Answer:
3) Develop a Python program that searches for a specific element in a list of strings. Print "Element found" if the element exists; otherwise, print "Element not found".
Answer:
4) Develop a Python program that creates a nested list representing a 3x3 matrix of integers. Then, print the matrix.
Answer:
5) Create a Python program that takes a list of integers as input and prints the sublist
containing elements from index 2 to index 5.
Answer: