Practical Assignment 5 - Lists
Practical Assignment 5 - Lists
Class XI
Lists
Q1. Write a menu driven program to allow the user to perform any of the list operation given in a
menu as follows:
1. Append an element
2. Insert an element
3. Append a list to the given list
4. Modify an existing element
5. Delete an existing element from its position
6. Delete an existing element from its position
7. Delete an existing element with a given value
8. Sort the list in ascending order
9. Sort the list in descending order
10. Display the list
Q2. The record of a student [Name, Roll No, Marks in five subjects and percentage of marks) is
stored in the following list
stRecord=[‘Raman’,’A-36’,[56,98,99,72,69],78.8]
Write Python program to retrieve the following information from the list stRecord.
a. Percentage of the student
b. Marks in the fifth subject
c. Maximum marks of the student
d. Roll number of the student
e. Change the name of the student from ‘Raman’ to ‘Raghav’
Q3. Write a program to find the number of times an element occurs in the list.
Q4. Write a program to read a list of n integers (positive as well as negative). Create two new lists,
one having all positive numbers and the other having all negative numbers from the given list. Print
all the three lists.
Q5. Write a function that returns the largest element of the list passed as parameter.
Q6. Write a function to return the second largest number from a list of numbers.
Q7. Write a program to read a list of n integers and find their median.
Note: The median value of a list of values is the middle value when they are arranged in
order. If there are two middle values then take their average.
Hint: You can use an built-in function to sort their average.
Q8. Write a program to read a list of elements. Modify this list so that it does not contain any
duplicate elements, i.e. all elements occurring multiple times in the list should appear once.
a. The program should ask for the position of the element to be deleted from the list.
Write a function to delete the element at the desired position in the list.
b. The program should ask for the value of the element to be deleted from the list.
Write a function to delete the element of this value from the list.
Q10. Read a list of n elements. Pass this list to a function which reverses this list in-place without
creating a new list.