Python List MCQs

This section focuses on the "list" in Python. These Multiple Choice Questions (mcq) should be practiced to improve the Python skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. Which of the following would give an error?.

A. list1=[]
B. list1=[]*3
C. list1=[2,8,7]
D. None of the above

View Answer


2. Which of the following is True regarding lists in Python?.

A. Lists are immutable.
B. Size of the lists must be specified before its initialization
C. Elements of lists are stored in contagious memory location.
D. size(list1) command is used to find the size of lists.

View Answer


3. What will be the output of below Python code?.

list1=[8,0,9,5]
print(list1[::-1])

A. [5,9,0,8]
B. [8,0,9]
C. [8,0,9,5]
D. [0,9,5]

View Answer


4. Which of the following will give output as [23,2,9,75] ?.

If list1=[6,23,3,2,0,9,8,75]

A. print(list1[1:7:2])
B. print(list1[0:7:2])
C. print(list1[1:8:2])
D. print(list1[0:8:2])

View Answer


5. The marks of a student on 6 subjects are stored in a list, list1=[80,66,94,87,99,95]. How can the student’s average mark be calculated?.

A. print(avg(list1))
B. print(sum(list1)/len(list1))
C. print(sum(list1)/sizeof(list1))
D. print(total(list1)/len(list1))

View Answer


6. What will be the output of following Python code?.

list1=["Python","Java","c","C","C++"]
print(min(list1))

A. c
B. C++
C. C
D. min function cannot be used on string elements

View Answer


7. The elements of a list are arranged in descending order. Which of the following two will give same outputs?
   i. print(list_name.sort())
   ii. print(max(list_name))
   iii. print(list_name.reverse())
   iv. print(list_name[-1]).

A. i, ii
B. i, iii
C. ii, iii
D. iii, iv

View Answer


8.  What will be the result after the execution of above Python code?.

list1=[3,2,5,7,3,6]
list1.pop(3)
print(list1)

A. [3,2,5,3,6]
B. [2,5,7,3,6]
C. [2,5,7,6]
D. [3,2,5,7,3,6]

View Answer


9. What will be the output of below Python code?.

list1=[1,3,5,2,4,6,2]
list1.remove(2)
print(sum(list1))

A. 18
B. 19
C. 21
D. 22

View Answer


10. What will be the output of below Python code?.

list1=["tom","mary","simon"]
list1.insert(5,8)
print(list1)

A. ["tom", "mary", "simon", 5]
B. ["tom", "mary", "simon", 8]
C. [8, "tom", "mary", "simon"]
D. Error

View Answer






Also check :


Discussion


* You must be logged in to add comment.