Python List MCQ : Set 1

Python List MCQ

1). What is a list in Python?

a) A collection of unordered elements
b) A collection of ordered elements
c) A collection of unique elements
d) A collection of numeric elements

Correct answer is: b) A collection of ordered elements
Explanation: A list in Python is an ordered collection of elements enclosed in square brackets.

2). How do you create an empty list in Python?

a) list()
b) []
c) emptylist()
d) create_list()

Correct answer is: b) []
Explanation: Using square brackets with no elements inside creates an empty list.

3). Which of the following is an invalid list declaration?

a) my_list = [1, 2, 3]
b) my_list = [“apple”, “cake”, “milk”]
c) my_list = [1, “apple”, True]
d) my_list = (1, 2, 3)

Correct answer is: d) my_list = (1, 2, 3)
Explanation: The invalid declaration is using parentheses instead of square brackets.

4). Which method is used to add an element at the end of a list?

a) add()
b) append()
c) extend()
d) insert()

Correct answer is: b) append()
Explanation: The append() method is used to add an element at the end of a list.

5). Which method is used to add multiple elements to a list?

a) add()
b) append()
c) extend()
d) insert()

Correct answer is: c) extend()
Explanation: The extend() method is used to add multiple elements to a list. Explanation: The extend() method adds the elements [6, 7, 8] to the end of the list.

6). How do you access the last element of a list?

a) list[-1]
b) list[0]
c) list[len(list) – 1]
d) list[last()]

Correct answer is: a) list[-1]
Explanation: Negative indexing allows you to access elements from the end of the list.

7). Which method is used to insert an element at a specific index in a list?

a) add()
b) append()
c) extend()
d) insert()

Correct answer is: d) insert()
Explanation: The insert() method is used to insert an element at a specific index in a list.

8). Which method is used to remove the element at a specific index from a list?

a) pop()
b) remove()
c) delete()
d) del

Correct answer is: d) del
Explanation: The del statement is used to remove the element at a specific index from a list.

9). How do you check if an element exists in a list?

a) check(element)
b) contains(element)
c) element in my_list
d) my_list.has(element)

Correct answer is: c) element in my_list
Explanation: The “in” operator checks if an element exists in a list.

10). Which method is used to get the number of occurrences of an element in a list?

a) count()
b) find()
c) index()
d) occurrences()

Correct answer is: a) count()
Explanation: The count() method returns the number of occurrences of an element in a list.

11). Which method is used to sort a list in ascending order?

a) sort()
b) order()
c) arrange()
d) ascending()

Correct answer is: a) sort()
Explanation: The sort() method is used to sort a list in ascending order.

12). Which method is used to sort a list in descending order?

a) sort()
b) order()
c) arrange()
d) descending()

Correct answer is: a) sort()
Explanation: The sort() method can also be used to sort a list in descending order.

13). Which method is used to reverse the order of elements in a list?

a) reverse()
b) flip()
c) invert()
d) swap()

Correct answer is: a) reverse()
Explanation: The reverse() method is used to reverse the order of elements in a list.

14). Which method is used to make a copy of a list?

a) copy()
b) duplicate()
c) clone()
d) replicate()

Correct answer is: a) copy()
Explanation: The copy() method is used to make a copy of a list.

15). Which method is used to clear all elements from a list?

a) clear()
b) remove_all()
c) delete_all()
d) reset()

Correct answer is: a) clear()
Explanation: The clear() method is used to remove all elements from a list.

16). Which operator is used to concatenate two lists?

a) +
b) &
c) |
d) %

Correct answer is: a) +
Explanation: The + operator is used to concatenate two lists.

17). Which method is used to convert a string into a list?

a) to_list()
b) convert()
c) split()
d) parse()

Correct answer is: c) split()
Explanation: The split() method is used to convert a string into a list by splitting it based on a delimiter.

18). Which method is used to convert a list into a string?

a) to_string()
b) convert()
c) join()
d) stringify()

Correct answer is: c) join()
Explanation: The join() method is used to convert a list into a string by joining the elements with a delimiter.


19). Which method is used to find the index of the first occurrence of an element in a list?

a) find()
b) locate()
c) index()
d) search()

Correct answer is: c) index()
Explanation: The index() method is used to find the index of the first occurrence of an element in a list.

20). Which method is used to remove and return the last element of a list?

a) pop()
b) remove()
c) extract()
d) take()

Correct answer is: a) pop()
Explanation: The pop() method removes and returns the last element of a list.

21). Which method is used to insert an element at a specific position in a list?

a) insert()
b) add()
c) place()
d) position()

Correct answer is: a) insert()
Explanation: The insert() method is used to insert an element at a specific position in a list.

22). Which method is used to remove the first occurrence of a specified element from a list?

a) remove()
b) erase()
c) delete()
d) discard()

Correct answer is: a) remove()
Explanation: The remove() method is used to remove the first occurrence of a specified element from a list.

23). Which method is used to extend a list by appending all the elements from another list?

a) extend()
b) expand()
c) concatenate()
d) attach()

Correct answer is: a) extend()
Explanation: The extend() method is used to extend a list by appending all the elements from another list.

24). Which method is used to count the number of occurrences of an element in a list?

a) count()
b) find()
c) locate()
d) search()

Correct answer is: a) count()
Explanation: The count() method is used to count the number of occurrences of an element in a list.

25). Which method is used to check if all elements in a list satisfy a certain condition?

a) all()
b) every()
c) each()
d) satisfy_all()

Correct answer is: a) all()
Explanation: The all() method is used to check if all elements in a list satisfy a certain condition.

Leave a Comment