Time: 45 Minutes MM: 50
Basic List Operations
1. Create a list of 5 numbers. Perform the following operations:
o Add a new number to the list.
o Remove the second element.
o Replace the last element with a new number.
o Print the length of the list.
2. Write a program to find the largest and smallest numbers in a list.
3. Create two lists: one containing names and the other containing their corresponding ages. Print each
name with its age using a loop.
4. Reverse a list without using the reverse() method.
List Slicing
1. Given a list of numbers, extract:
o The first 3 elements.
o The last 2 elements.
o Every second element from the list.
2. Write a program to split a list into two halves.
List Comprehensions
1. Generate a list of squares of numbers from 1 to 10 using list comprehension.
2. Filter out all even numbers from a given list using list comprehension.
3. Create a new list that contains only the words with more than 3 characters from an existing list of
strings.
Nested Lists
1. Create a 3x3 matrix as a nested list and print each row on a new line.
2. Flatten a nested list into a single list using either loops or list comprehension.
Advanced Challenges
1. Write a program to remove duplicates from a list while maintaining the original order.
2. Given two lists, create a new list containing only the common elements between them.
3. Sort a list of tuples based on the second element in each tuple (e.g., [(1, 3), (4, 2), (5, 1)] →
[(5, 1), (4, 2), (1, 3)]).
These exercises cover foundational concepts like indexing, slicing, comprehensions, and nested lists, which are
essential for mastering Python lists!