Python Programming - Lists
Exercise : Lists - General Questions
- Lists - General Questions
61.
What does the
list.remove(42)
method do in Python?
Answer: Option
Explanation:
The
remove()
method in Python lists removes the first occurrence of a specific element.
62.
How can you reverse the order of elements in a list without modifying the original list?
Answer: Option
Explanation:
Using slicing
[::-1]
creates a new list with the reversed order of elements.
63.
What will the
list.extend([7, 8, 9])
method do?
Answer: Option
Explanation:
The
extend()
method adds individual elements from the iterable to the end of the list.
64.
How can you find the frequency of each element in a list in Python?
Answer: Option
Explanation:
Using
Counter
and dict()
can create a dictionary with element frequencies.
65.
How can you create a list containing only the unique elements from another list in Python?
Answer: Option
Explanation:
Converting a list to a set removes 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