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([Link]('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’]
[Link](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. [Link](23)
6. print(L1)
7. print(sum(L1))
8. print(min(L1))
9. print(max(L1))
[Link](-1, 'a')
[Link](L1)
[Link]([Link]())
[Link]([1, 2, 3])
[Link](L1)
[Link]([4, 5, 6])
[Link](L1)
[Link]([Link]('a'))
[Link]('a')
[Link](L1)
[Link]([Link](4))
[Link](L1)