Python Programming - Lists
Exercise : Lists - General Questions
- Lists - General Questions
6.
Which of the following methods is used to insert an element at a specific index in a list?
Answer: Option
Explanation:
The
insert(index, element)
method is used to insert an element at a specific index in a list.
7.
How can you reverse the order of elements in a list in Python?
Answer: Option
Explanation:
The
list.reverse()
method is used to reverse the order of elements in a list in-place.
8.
What is the purpose of the
count
method in Python lists?
Answer: Option
Explanation:
The
count
method in Python lists is used to count the number of occurrences of a specific element.
9.
Which method is used to remove the first occurrence of a specific element from a list?
Answer: Option
Explanation:
The
remove(element)
method is used to remove the first occurrence of a specific element from a list.
10.
What is the correct way to create a new list by multiplying each element of an existing list by 2 in Python?
Answer: Option
Explanation:
The correct way to create a new list by multiplying each element of an existing list by 2 is using a list comprehension as shown in option B.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers