Python Programming - Lists
Exercise : Lists - General Questions
- Lists - General Questions
21.
Which method is used to add an element at the end of a list in Python?
Answer: Option
Explanation:
The
append()
method is used to add an element at the end of a list in Python.
22.
How can you find the index of the last occurrence of a specific element in a list?
Answer: Option
Explanation:
The
rindex()
method is used to find the index of the last occurrence of a specific element in a list.
23.
What does the
copy()
method do in Python lists?
Answer: Option
Explanation:
The
copy()
method in Python lists is used to create a shallow copy of the list.
24.
What is the purpose of the
extend
method in Python lists?
Answer: Option
Explanation:
The
extend()
method in Python lists is used to extend the list by appending elements from an iterable.
25.
How can you remove all occurrences of a specific element from a list?
Answer: Option
Explanation:
To remove all occurrences of a specific element, you can use a list comprehension to filter out the unwanted element.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers