MCQ Single Best Answer Not Set

QSelect all the correct ways to copy two sets

ID: #3809 Python Set MCQ 212 views
Question Info
#3809Q ID
Not SetDifficulty
Python Set MCQTopic

Choose the Best Option

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

  • A set2 = set1.copy() set2 = set(set1) set2.update(set1)
  • B set2 = set1
Correct Answer: Option A

Explanation

When you set set2= set11, you are making them refer to the same dict object, so when you modify one of them, all references associated with that object reflect the current state of the object. So don’t use the assignment operator to copy the set instead use the copy() method or set() constructor.

Share This Question

Challenge a friend or share with your study group.