Python Programming - Sets
Exercise : Sets - General Questions
- Sets - General Questions
11.
Which method is used to remove all elements from a set?
Answer: Option
Explanation:
The
clear() method is used to remove all elements from a set.
12.
What is the result of the expression
set('programming') | set('python')?
Answer: Option
Explanation:
The '|' operator performs the union of two sets, combining unique elements.
13.
How can you check if two sets have no elements in common?
Answer: Option
Explanation:
The
isdisjoint() method checks if two sets have no elements in common.
14.
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.
15.
What does the
frozenset() function do?
Answer: Option
Explanation:
The
frozenset() function is used to create an immutable set in Python.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers