0% found this document useful (0 votes)
4 views

Assignment on lists

The document is an assignment for Class XI at Delhi Public School, Gurgaon, focused on working with lists in Python. It includes definitions, explanations, and programming tasks related to list operations such as traversal, slicing, and various list methods. The assignment also contains coding exercises that require students to manipulate lists, search for values, sort numbers, and predict outputs of given code snippets.

Uploaded by

Soham Mukherjee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment on lists

The document is an assignment for Class XI at Delhi Public School, Gurgaon, focused on working with lists in Python. It includes definitions, explanations, and programming tasks related to list operations such as traversal, slicing, and various list methods. The assignment also contains coding exercises that require students to manipulate lists, search for values, sort numbers, and predict outputs of given code snippets.

Uploaded by

Soham Mukherjee
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Delhi Public School, Gurgaon

Topic: Working with Lists in Python


Class XI(2021-22)
Assignment

1. Define List.
2. What do you mean by traversal of a List?
3. Explain the concept of slicing with the help of an example.
4. What is the difference between append() and extend() in list?
5. How do we convert a string value into a list?
6. Assuming that A is a list, differentiate between:
(i) A[2] and A[2:]
(ii) A[2:] and A[:2]
7. Consider the list list1=[”Computer Science”,”physics”,”chemistry”,”maths”,”English”] write
statements in python to implement the following:
a) To display last 3 elements of the list.
b) To display the part of list starting from index 1 to index 3(both inclusive).
c) To check if the list has alphanumeric values or not.
d) To display the index for the value “physics”.
e) To delete the last element of the list.
f) To replace the subject “English” with “Core English”
g) To display the number of elements in a list.

8. Write programs for the following:


a) To create a list of 10 numbers and search for a value entered by the user.
b) To sort the list of 10 numbers in descending order.
c) To find the maximum and minimum values from a list of 10 numbers.
d) To delete all duplicate elements from a list. For example list1=[1,2,3,2,1]then,output
should be list1=[1,2,3]
e) To arrange negative numbers to the left and positive numbers to the right of the list.For
example: list1=[3,-5,1,3,7,0,-15,3,-7,-8] .then result should be [-5.-15,-7,-8,3,1,3,7,0,3]
f) To display names of students whose name starts with ‘S’ from a given list of 10 names.

1
g) To print the diagonal values of a 3x3 matrix.
h) To replace all the even values present in the list of 10 numbers by add 5 to it.
9. Predict the output of the following codes:
a) L1 = list('4320187')
L1[0] = L1[5] = 0
L1[3] = L1[-2]
print(L1)
b) l1=[1,2,3]
print(l1*2)
c) a=[[[1,2],[3,4],5],[6,7]]
print(a[0][1][1])
d) a,b =[3,2,1],[5,4,6]
print(a+b)
e) a=[2,1,3,5,4]
a.remove(2)
print (a)

10.Convert and predict the output for the following code using list comprehension to a simple
python code:
a) pow2=[2**x for x in range(10) if x>5]
pow2
b) l=[x+y for x in [‘python’,’c’]for y in [‘language’,’programmoing’]]
print(l)

You might also like