Python Programming - Lists
Exercise : Lists - General Questions
- Lists - General Questions
31.
What does the
clear()
method do in Python lists?
Answer: Option
Explanation:
The
clear()
method in Python lists is used to remove all elements from the list, leaving it empty.
32.
What is the purpose of the
reverse()
method in Python lists?
Answer: Option
Explanation:
The
reverse()
method in Python lists is used to reverse the order of elements in-place.
33.
What is the purpose of the
sort()
method in Python lists?
Answer: Option
Explanation:
The
sort()
method in Python lists is used to sort the list in ascending order.
34.
How can you find the average of elements in a numeric list in Python?
Answer: Option
Explanation:
The average of elements in a numeric list is calculated as the sum divided by the number of elements.
35.
How can you create a new list containing only the unique elements from an existing list in Python?
Answer: Option
Explanation:
Using
set()
to remove duplicates and then converting it back to a list creates a new list with unique elements.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers