Python Programming - Lists
Exercise : Lists - General Questions
- Lists - General Questions
1.
How do you remove an element from a list in Python?
Answer: Option
Explanation:
The
pop(index)
method is used to remove and return the element at the specified index in a list.
2.
Which method is used to add elements from one list to another in Python?
Answer: Option
Explanation:
The
extend()
method is used to add elements from one list to the end of another list.
3.
What is the correct way to sort a list in descending order in Python?
Answer: Option
Explanation:
The
list.sort(reverse=True)
method is used to sort a list in descending order in-place.
4.
What does the
index
method of a list return in Python?
Answer: Option
Explanation:
The
index
method returns the index of the first occurrence of the specified element in a list.
5.
Which function is used to create a shallow copy of a list in Python?
Answer: Option
Explanation:
The
copy()
function is used to create a shallow copy of a list in Python.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers