0% found this document useful (0 votes)
6 views3 pages

Worksheet - LISTS

The document is a worksheet for St. Joseph's School focusing on computer science and lists in Python. It contains various exercises asking for outputs of print statements involving list manipulations, including slicing, appending, and modifying lists. The exercises are designed to test students' understanding of list operations and indexing in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Worksheet - LISTS

The document is a worksheet for St. Joseph's School focusing on computer science and lists in Python. It contains various exercises asking for outputs of print statements involving list manipulations, including slicing, appending, and modifying lists. The exercises are designed to test students' understanding of list operations and indexing in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ST JOSEPH’S SCHOOL

SUBJECT – COMPUTER SCIENCE


LISTS - WORKSHEET
1. Write the output of the following print statements
L = [23, 34, 12, 65, 43, 25, 36, 89]
print(L[2 : 2])
print(L[3 : 7])
print(L[: : -1])
print(L[-6 : -1])

2. Write the output of the following:


L = [[23, 34, 12], [65, 43, 25,], [36, 89]]
print(L[2 : 2])
print(L[3 : 7])
print(L[: : -1])
print(L[-6 : -1])

3. Write the output of the following :


L = [[2, 3, -1], [‘One’, ‘Two’, ‘Three’], [ 9]]
for i in L:
print(i)
4. Write the output of the following :
L = [[2, 3, -1], ['One', 'Two', 'Three'], [ 9]]
for i in L:
print( i + i )

4. Write the output of the following :


L = [['12', '3', '-1'], ['One', 'Two', 'Three'], [ 9]]
for i in L:
print(i[0]+i[0])
5. Write the output of following code:
L = [['12', '3', '-1'], ['One', 'Two', 'Three'], [ 9]]
for i in range(3):
print(L.append('four'))
print(L)

6. Write the statement for doing the following task and also write the final list after
performing all the given task.
L = [‘Amit’ , ‘Sumit’, ‘Mini’ , ‘Ronit’ , ‘Abdul’]
Add name ‘Suman’ after ‘Sumit’
Add name ‘Mukesh’ at the end.
Remove the first name of the list .

7. Write the output of the following :


L = [‘Amit’ , ‘Sumit’, ‘Mini’ , ‘Ronit’ , ‘Abdul’]
L.insert(2, (‘Suman’,’Robin’, ‘jack’))
print(L)

8. Write the output of the following:


L1 = [11, 22, 33, 44, 55, 66, 77, 88, 99]
1. print(L1[0]) 12. print(L1[-1 : -4])
2. print(L1[-0]) 13. print(L1[: : 2])
3. print(L1[-6]) 14. print(L1[2 : 8 : 2])
4. print(L1[-11]) 15. print(L1[: 5 : 2])
5. print(L1[7]) 16. print(L1[1 : 6 : 3])
6. print(L1[3+5]) 17. print(L1[3 : 10 : 2])
7. print(L1[7-2]) 18. print(L1[: : -1])
8. print(L1[3 : 8]) 19. print(L1[-8 : -3 : 2])
9. print(L1[2 : 6]) 20. print(L1[7 : 9 : 2])
10. print(L1[-8 : -2])
11. print(L1[7 : 2])
9. Write the output of the following
L1 = [11, 22, 33]
1. print(L1+L1)
2. print(L1 * 2)
3. print(L1 * 1)
4. print(L1 * -2)
5. L1.append(23)
6. print(L1)
7. print(sum(L1))
8. print(min(L1))
9. print(max(L1))
10.L1.insert(-1, 'a')
11.print(L1)
12.print(L1.pop())
13.L1.extend([1, 2, 3])
14.print(L1)
15.L1.append([4, 5, 6])
16.print(L1)
17.print(L1.index('a'))
18.L1.remove('a')
19.print(L1)
20.print(L1.pop(4))
21.print(L1)

You might also like