R4RIN
MCQS
Python MCQ Quiz Hub
MCQ on List in Python
Choose a topic to test your knowledge and improve your Python skills
1. Which of the following statement will create list?
a. L1=list( )
L1=[1,2,3,4]
Both of the above
None of the above
2. Write the output of the following code : list(“welcome”)
[‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’]
(‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’)
[‘welcome’]
None of the above
3. Write the output of the following code : >>> L=[‘w’,’e’,’l’,’c’,’o’,’m’,’e’] >>> print(len(L))
7
8
9
None
4. Write the output of the following code : >>> L=[“Amit”,”Anita”,”Zee”,”Longest Word”] >>> print(max(L))
Zee
Longest Word
Error
None of the above
5. Write the output of the following code : >>> L=[“Amit”,”Anita”,”Zee”,”Longest Word”,123] >>> print(max(L))
Longest Word
Zee
Amit
Error
6. Write the output of the following code : >>>L=[1,5,9] >>>print(sum(L),max(L),min(L))
15 9 1
Error
Max and Min are only for String Value
None of the above
7. Write the output of the following code : >>>L=[1,2,3,4,5,[6,7,8]] >>>print(L[5])
[6, 7, 8]
6, 7, 8
Error
6
8. Write the output of the following code : L=list(“www.csiplearninghub.com”) print(L[20 : -1])
[‘c’ , ‘o’]
[‘c’ , ‘o’ , ‘m’]
(com)
Error
9. Write the output of the following code : >>>L=list(“www.csiplearninghub.com”) >>>print(L[20 : 0])
Error
No Value
None
[ ]
10. Write the output of the following code : >>>L=[“Amit”,”Sumit”,”Naina”] >>>print(L[-1][-1])
[Naina]
[a]
a
None of the above
11. Write the output of the following code : >>>L=[“Amit”,”Sumit”,”Naina”] >>>print(L[1:-1])
[‘Sumit’]
[a]
[Naina]
None of the above
12. Write the output of the following code : L=[“Amit”,”Sumit”,”Naina”] print(L*2)
[‘Amit’, ‘Sumit’, ‘Naina’, ‘Amit’, ‘Sumit’, ‘Naina’]
[“Amit” , “Sumit” , “Naina”]
Error
None of the above
13. Write the output of the following code : L=[“Amit”,”Sumit”,”Naina”] print(L**2)
Error
[“Amit”,”Sumit”,”Naina”][“Amit”,”Sumit”,”Naina”]
[“Amit”,”Sumit”,”Naina”]
[“Amit”,”Sumit”,”Naina”,”Amit”,”Sumit”,”Naina”]
14. Write the output of the following code : L=[0.5 * x for x in range(4)] print(L)
[0.0, 0.5, 1.0, 1.5]
(0,.5, 1, 1.5)
[0.0, 0.5, 1.0, 1.5, 2.0]
Error
15. Write the output of the following code : L=[‘a’ * x for x in range(4)] print(L)
[‘ ‘ , ‘a’ , ‘aa’ , ‘aaa’]
[‘a’, ‘aa’, ‘aaa’]
Error
None of the above
16. Write the output of the following code : L= [1*x for x in range(10,1,-4)] print(L)
[10, 6, 2]
[10, 7, 4]
Error
None of the above
17. Write the output of the following code : L=[1,2,3,4,5] for i in L: print(i,end=” “) i=i+1
1, 2, 3, 4, 5
1, 3, 5
Error
None of the above
18. Write the output of the following code : L=[“Amit”,”Sumit”,”Naina”] L1=[“Sunil”] print(L + L1)
[‘Amit’ , ‘Sumit’ , ‘Naina’ , [‘Sunil’]]
[‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’]
List can not concatenate
None of the above
19. Which command is used to add an element in List named L1
L1.add(4)
L1.append(4)
L1.new(4)
None of the above
20. Write the output of the following : L = “123456” L = list(L) print(type(L[0]))
class ‘str’
class ‘int’
1
Error
21. Write the output of the following: T=(1,2,3,4,5.5) L = list(T) print(L[3]*2.5)
Error
10
10.0
4
22. Write the output of the following: T=(1,2,3,4,5.5) L = list(T) print(L*2)
[2, 4, 6, 8, 11]
[1, 2, 3, 4, 5.5, 1, 2, 3, 4, 5.5]
Error
None of the above
23. Write the output of the following: T = [1,2,3,4] T1 = [3,4,5,6] T2 = T + T1 print(T2)
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 3, 4, 5, 6]
[4, 6, 8, 10]
Error
24. Write the output of the following: T = [1,2,3,4] T1 = [3,4,5,6] T2 = T.append(T1) print(T2)
[1, 2, 3, 4, [3, 4, 5, 6]]
[1, 2, 3, 4, 3, 4, 5, 6]
None
None of the above
25. del statement can delete the following from the List?
Single Element
Multiple Elements
All elements along with List object
All the above
26. Write the output of the following: T = [1,2,3,4] T1=T T[0] = “A” print(T) print(T1)
['A', 2, 3, 4] [1, 2, 3, 4]
['A', 2, 3, 4] ['A', 2, 3, 4]
[1, 2, 3, 4] [1, 2, 3, 4]
Error
27. What type of error is returned by the following statement? T = [1,2,3,4] print(T.index(9))
IndexError
TypeError
ValueError
None of the above
28. Write the output of the following. T = [1,2,3,4] T1=[5,6,7] L=T.append(T1) print(L)
None
[1, 2, 3, 4, [5, 6, 7]]
[ ]
Error
29. Write the output of the following: L=["Amit","Sumit","Naina"] L1=["Sunil"] print(L + L1)
[“Amit” , “Sumit” , “Naina” , [“Sunil”] ]
[‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’]
Error
[‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’][‘Amit’ , ‘Sumit’ , ‘Naina’ , ‘Sunil’]
30. What we call the operation which is used to extract particular range from a sequence.
Slicing
range
Indexing
Replication
31. Write the output of the following : L=[2 * x for x in range(3,14,3)] print(L)
[6, 12, 18, 24]
[6, 12, 18]
[6, 12, 18, 24, 30]
Error
32. Write the output of the following : L=["Amit","Sumit","Naina"] L1=["Sumit"] print(L - L1)
[“Amit” , “Naina”]
[“Amit” , “Naina”, “Sumit”]
Show Error
Error
33. Write the output of the following:
Error
14 + 9 -1
23
24
34. Write the output of the following:
Error
14 + 9 -1
23
24
35. Write the output of the following:
Error
14 + 9 -1
23
24
36. Which mathematical operator is used for repetition?
*
**
+
//
37. Which of the following is not list operation?
Indexing
Slicing
Dividing
Concatenation
38. Which of the following is true about List data type in Python?
List is a Sequence data type
List is mutable
List can have elements of different data type
All the above
39. Identify data type of ‘T’ in following line of Code: T = list(tuple([1,2,3])) print(type(T))
Tuple
List
Nested List
None of the above
40. List and String are different
in reference to their indexing
in reference to data type of elements they contain
Both of the above
None of the above
41. List can have elements of _____________ data types.
Same
Different
Both of the above
None of the above
42. Write the output of the following: L =[['Physics',101],['Chemistry',202], ['Maths',303],45, 6, 'j'] print(len(L))
3
4
5
6
43. Write the output of the following : L = [1,2,3,4,5,6,7,8,9,10] print(L[L[3]])
3
4
5
6
44. Which of the following statement will return first element from right of list ‘L’?
L[0]
L[-1]
L[1]
None of the above
45. Write the output of the following: L = [1,2,3,4,5,6,7,8,9,10] print(L[len(L) - 1])
9
1
Error
None of the above
46. The following statements is showing ______ operation in List. L1 = [1,2,3,4] L2 = [1,2,3,4] L = L1 + L2
Replication of List
Concatenation of String
Indexing of String
None of the above
47. Which mathematical operator is used to concatenate list?
+
//
**
None of the above
48. Write the output of the following : L1 = [1,2,3] L2=[5,6,7] L1 + L2 print(L1)
[1, 2, 3, 4, 5, 6, 7]
[1, 2, 3, 5, 6, 7]
[1, 2, 3]
None of the above
49. If we try to concatenate a list with elements of some other data type, _____________ occurs.
SyntaxError
SyntaxError
TypeError
None of the above
50. If we try to concatenate a list with elements of some other data type, _____________ occurs.
SyntaxError
SyntaxError
TypeError
None of the above
51. If we try to concatenate a list with elements of some other data type, _____________ occurs.
SyntaxError
SyntaxError
TypeError
None of the above
52. If we try to concatenate a list with elements of some other data type, _____________ occurs.
SyntaxError
SyntaxError
TypeError
None of the above
53. Name the operator which is used in the following print statement.
Concatenation
Repetition
Membership
None of the above
54. Which operator helps to check whether an element is present in list or not?
+
in
**
None of the above
55. Write the output of the following: print(1 in [[1],2,3])
True
False
Error
None of the above
56. Which operation of List is shown in following lines? L1 = [1, 2, 3, 4, 5, 6, 7, 8] print(L1[3 : 6])
Concatenation
Repetition
Slicing
None of the above
57. Which of the following statement will reverse the list L1?
L1[ : : 1]
L1[-1 : : -1]
L1[: : -1]
None of the above
58. Traversing a list can be done with the help of _____
loop
if
if–elif
None of the above
59. Write the output of the following: print(len(tuple[1]))
1
0
Error
None of the above
60. Write the output of the following : L = [[1,2,3,5,6,7,[1,[2,3]]]] print(len(L))
4
3
2
1
61. Which function returns the length of a list?
Len( )
length( )
len( )
Length( )
62. Write the output of the following : D = list[ ] print(len(D))
0
1
SyntaxError
ValueError
63. remove( ) function removes the _______________ occurrences of an element from the list
all
first
last
None of the above
64. Which of the following function creates the new list?
sort( )
sorted( )
reverse( )
All the above
65. Write the output of the following : D = [1,2,3] D1 = D D.append(4) print(D1)
[1, 2, 3, 4]
[1, 2, 3]
Error
None of the above
66. Fill in the blanks with same word in both places >>> import __________ >>> list1 = [1,2,3,4,5] >>> list2 = _________copy(list1) >>> list2
copy
pickle
math
None of the above
67. Write the output of the following : def listchange(L): L.append(45) return L1 = [1, 2, 3, 4] listchange(L1) print(L1)
[1, 2, 3, 4]
[1, 2, 3, 45]
[1, 2, 3, 4, 45]
None of the above
68. Write the output of the following: print([] * 2 )
[ ]
0
Error
None of the above
69. Which of the following will give output as [21,2,9,7] ? if list L = [1,21,4,2,5,9,6,7]
print(L[1 : 8 : 2])
print(L[1 : : 2])
Both of the above
None of the above
70. Write the output of the following : L = ['Amit', 'anita', 'Sumant', 'Zaid'] print(max(L))
Zaid
Sumant
anita
Amit
71. Write the output of the following: L=[13, 12, 15, 27, 3, 46] list1.pop(3) print(L)
[13,12,15, 27, 46]
[13, 12, 15, 3, 46]
[13, 12, 15, 27, 3]
None of the above
72. Write the output of the following: list1=[3,2,5,7,3,6] list1.remove(3) print(sum(list1))
23
20
15
None of the above
73. Write the output of the following list1=[3,2,5,7,3,6] list1.insert(6,3) print(list1)
[3, 2, 5, 6, 7, 3, 6]
[3, 2, 5, 6, 3, 6]
[3, 2, 5, 7, 3, 6, 3]
None of the above
74. Write the output of the following L = [14, 2, 3, 16, 15] L[1:4] = [5, 4, 8] print(L)
[14, 5, 4, 8, 15]
[14, 5, 4, 8, 2, 3, 16, 15]
Error
None of the above
75. Write the output of the following L = ["Amit", 'Sumit', 'Ravi'] print(L[0][1])
A
Amit
s
m
76. Write the output of the following L = ["Amit", 'Sumit', 'Ravi'] print("@".join(L))
@Amit
Amit@Sumit@Ravi
Amit@Sumit@Ravi@
None of the above
77. Write the output of the following: L = ['A', 'S', 'R'] L = L + L*2 print(L)
[‘A’, ‘S’, ‘R’, ‘2A’, ‘2S’, ‘2R’]
[‘A’, ‘S’, ‘R’, ‘A’, ‘S’, ‘R’, ‘A’, ‘S’, ‘R’]
[‘A’, ‘S’, ‘R’]
Error
78. Write the output of the following : L = [[5, 7, 9, 1 ], [12, 23, 4, 9]] for r in L: r.reverse( ) for e in r: print(e, end = ” “)
1 9 7 5 9 4 23 12
1 9 7 5 9 4 23 12
Error
None of the above
79. Write the output of the following: L = [[5, 7, 9, 1 ], [12, 23, 4, 9]] for r in L: r.sort() for e in r: print(e, end = ” “)
1 5 7 9 4 9 12 23
1 4 5 7 9 9 12 23
9 7 5 1 23 12 9 4
None of the above
80. How many elements will be there in list ‘L’ L = [[p, q] for p in (0, 4) for q in (0, 4)]
2
4
8
16
81. Write the output of the following: L = [[p, q] for p in (0, 4) for q in (0, 4)] print(L[0])
[0]
[0, 4]
[4, 4]
[0, 0]
82. Write the output of the following: L = [23, 45, 65, 32, 3] L.insert(L[4], 'Monitor') print(L)
[23, 45, 65, ‘Monitor’, 32, 3]
[23, 45, 65, 32, ‘Monitor’, 3]
[23, 45, 65, 32, 3, ‘Monitor’]
None of the above
83. Which statement will give the same output? list1 = [1, 2, 3, 4] list2 = [5, 6, 7, 8]
print(len(list1 + list2))
print(len(list1) + len (list2))
print(list2[3])
All the above
84. Write the output of the following: L = [11, 21, 31, 41] L.append([51,62,73,84]) print(len(L))
8
5
4
None of the above
85. Write the output of the following : L = [11, 21, 31, 41] L.extend([51,62,73,84]) print(len(L))
8
5
4
Error
86. Write the output of the following L1 = ['C++', 'C-Sharp', 'Visual Basic'] L2 = [name.upper() for name in L1] L3 = [name for name in L1] if(L2[2][0] == L3[2][0]): print("YES") else: print("N0")
NO
yes
Error
None of the above
87. Write the output of the following : L = [11, 22, 33, 44, 55, 66] for i in range(1, 6): L[i - 1] = L[i]*2 for i in range(0, 4): print(L[i], end = " ")
44 66 88 110
22 33 44 55
11 22 33 44
Error
88. Write the output of the following : L= [1,2,3,4,5] m = [m and 1 for m in L] print(m)
[1, 2, 3, 4, 5]
[1, 1, 1, 1, 1]
[1, 0, 1, 0, 1
None of the above
89. Write the output of the following : L= [1,2,3,4,5] m = [m + 3 for m in L] print(m)
[4, 5, 6, 7, 8, 9]
[4, 5, 6, 7, 8, 9, 10]
[4, 5, 6, 7, 8]
Error
90. Write the output of the following : L1 = [1, 2, 3, 4, 5] L2 = [9, 8, 7, 6, 5] S= [L1 + 3 for L1 in L2] print(S)
12, 11, 10, 9, 8]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[4, 5, 6, 7, 8]
Error
91. Write the output of the following : L1 = [1, 2, 3] L2 = [9, 8] S= [m * n for m in L1 for n in L2] print(S)
[9, 8, 18, 16, 27, 24]
[9, 18, 27, 8, 16, 24]
[8, 9, 16, 18, 24, 27]
Error
92. Write the output of the following : L1 = [1, 2, 3] L2 = [9, 8] S= [n + m for m in L1 for n in L1] print(S)
[2, 3, 4, 3, 4, 5, 4, 5]
[1, 2, 3, 2, 3, 4, 3, 4, 5]
[2, 3, 4, 3, 4, 5, 4, 5, 6]
Error
93. Which of the following statement will generate the square of given list L ? L = [1, 2, 3, 4, 5]
[x ** 2 for x in L
[x * 2 for x in L]
[x ^ 3 for x in L
None of the above
94. Which of the following function is used to shuffle the list ?
random( )
swap( )
shuffle( )
None of the above
95. Which of the following command will insert 7 in third position of List L.
L.insert(3, 7)
L.insert(2, 7)
L.add(3, 7)
L.append(3, 7)
Submit