Single Choice
Not Set
QWhat is the output of the following set operation.
set1 = {"Yellow", "Orange", "Black"}
set2 = {"Orange", "Blue", "Pink"}
set1.difference_update(set2)
print(set1)
ID: #3811
Python Set MCQ
344 views
Question Info
#3811Q ID
Not SetDifficulty
Python Set MCQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
{‘Black’, ‘Yellow’}
The difference_update() method removes the items that exist in both sets. Here set1.difference_update(set2) removed the unwanted items from the original set1.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic