Python Programming - Sets
Exercise : Sets - General Questions
- Sets - General Questions
16.
How do you find the difference between two sets?
Answer: Option
Explanation:
The
difference()
method is used to find the difference between two sets.
17.
What is the result of the expression
set('python').intersection(set('java'))
?
Answer: Option
Explanation:
The
intersection()
method finds common elements, and in this case, there are none.
18.
What is the purpose of the
set.discard(element)
method?
Answer: Option
Explanation:
The
discard()
method removes the specified element from the set, if present.
19.
Which method is used to find the union of two sets?
Answer: Option
Explanation:
The
union()
method is used to find the union of two sets.
20.
Which of the following statements about frozensets in Python is correct?
Answer: Option
Explanation:
Frozensets are immutable and can be used as dictionary keys or elements of other sets.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers