Python Programming - Sets
Exercise : Sets - General Questions
- Sets - General Questions
36.
What is the result of the expression
set('python').isdisjoint(set('java'))
?
Answer: Option
Explanation:
The
isdisjoint()
method returns True if two sets have no elements in common.
37.
How do you find the elements common to multiple sets?
Answer: Option
Explanation:
The
intersection()
method with the asterisk (*) operator is used to find common elements in multiple sets.
38.
Which method is used to remove a specific element from a set, raising an error if the element is not present?
Answer: Option
Explanation:
The
remove()
method removes a specific element, raising an error if the element is not present.
39.
What is the result of the expression
set('python') | set('java')
?Answer: Option
Explanation:
The '|' operator performs the union of two sets, combining unique elements.
40.
What is the purpose of the
set.symmetric_difference(other_set)
method?
Answer: Option
Explanation:
The
symmetric_difference()
method returns the elements that are unique to each set.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers