Programming Language Python Set MCQ Question #3811
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

Choose the Best Option

Click any option to instantly check if you're correct.

  • A {
  • B {
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.

Share This Question

Challenge a friend or share with your study group.