Python MCQ and Answers – Lists
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer focuses on “Lists”.
1. Which of the following declarartion will create a list?
A mylist = list()
B mylist = []
C mylist = list([0, 0, 0])
D All of the above
2. Which of the following declarartion can raise an error?
A mylist = []
B mylist = [] * 2
C mylist = [1, 2, 3]
D None of the mentioned
3. Which of the following statement is True concerning lists in Python?
A The size of the lists should be given before their initialization
B size(mylist) function is used to find the size of lists
C Items of lists are saved in a contagious memory location
D Lists are unchangeable.
4. What is the output when we execute the following code list("welcome")
?
A [‘w’, ‘e’, ‘l’, ‘c’, ‘o’, ‘m’, ‘e’]
B [‘welcome’]
C [“w”, “e”, “l”, “c”, “o”, “m”, “e”]
D [“welcome”]
5. What is the output of the following code?
mylist = ["PHP", "Scala", "C", "C++", "Ada"] print(min(mylist))
A C
B C++
C Scala
D Ada
6. What is the output of the following code?
mylist = [5,0,5,0,0,5] mylist.pop(5) print(mylist)
A [5, 0, 5, 0, 0, 5]
B [5, 0, 5, 0, 0]
C [0, 5, 0, 0, 5]
D [5, 0, 5, 0, 0, 5, 5]
7. What is the output of the following code?
mylist = [1, 2, 3] mylist.remove(1) print(sum(mylist))
A 6
B 5
C 4
D 1
8. What is the output of the following code?
mylist = ['h', 'e', 'l', 'l', 'o'] print(len(mylist))
A 4
B 5
C 6
D Compilation error
9. What is the output of the following code?
mylist = ["A", "B", "C"] mylist.insert(3,2) print(mylist)
A [‘A’, ‘B’, 2, ‘C’]
B [‘A’, ‘B’, ‘C’, 2, 3]
C [‘A’, ‘B’, ‘C’, 3, 2]
D [‘A’, ‘B’, ‘C’, 2]
10. What is the output of the following code?
mylist = ["A", "B", "C", "D"] print(mylist[-1])
A D
B C
C B
D A