Python Programming - Sets
Exercise : Sets - General Questions
- Sets - General Questions
21.
What does the
set.symmetric_difference_update(other_set)
method do?
Answer: Option
Explanation:
The
symmetric_difference_update()
method modifies the set with elements unique to each set.
22.
What is the result of the expression
len(set("python"))
?
Answer: Option
Explanation:
The
set("python")
creates a set of unique characters, and the length is 6.
23.
Which method is used to update a set with elements from another set or iterable?
Answer: Option
Explanation:
The
update()
method is used to update a set with elements from another set or iterable.
24.
What is the result of the expression
set([1, 2, 3]) & set([2, 3, 4])
?
Answer: Option
Explanation:
The '&' operator performs the intersection of two sets, giving elements common to both sets.
25.
Which method is used to remove and return the last element from a set?
Answer: Option
Explanation:
The
pop()
method removes and returns an arbitrary element, which is the last element in a set.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers