0% found this document useful (0 votes)
3 views2 pages

List Assg

The document outlines a programming assignment involving list operations, including appending, inserting, modifying, deleting, and sorting elements. It also includes questions about the output of specific list manipulations and the effects of certain operations on lists. Additionally, it discusses the differences between various multiplication operations on a list.

Uploaded by

kirti.trikha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

List Assg

The document outlines a programming assignment involving list operations, including appending, inserting, modifying, deleting, and sorting elements. It also includes questions about the output of specific list manipulations and the effects of certain operations on lists. Additionally, it discusses the differences between various multiplication operations on a list.

Uploaded by

kirti.trikha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

LIST ASSIGNMENT

Q1.Write a program to allow user to perform any those list operation given in
a menu. The menu is:
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 with a given value
7. Sort the list in the ascending order
8. Sort the list in descending order
9. Display the list.

Q2. What will be the output of the following statements?


a) list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
b) list1 = [12,32,65,26,80,10]
sorted(list1)
print(list1)
c) list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]
d) list1 = [1,2,3,4,5]
list1[len(list1)-1]

Q3. Consider the following list myList. What will be the elements of myList
after each of the following operations?
myList = [10,20,30,40]

a) myList.append([50,60])
b) myList.extend([80,90])

Q4. What will be the output of the following code segment?


a) myList = [1,2,3,4,5,6,7,8,9,10]
del myList[3:]
print(myList)

b) myList = [1,2,3,4,5,6,7,8,9,10]
del myList[:5]
print(myList)
c) myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)

Q5. Consider a list:


list1 = [6,7,8,9]

What is the difference between the following operations on list1:


a) list1 * 2
b) list1 *= 2
c) list1 = list1 * 2

You might also like