Sets Assignment
By: Momina Ali
i. Add (): ~ adds an element to the set only if it does not exist.
Code:
Output:
ii. Clear(): ~Removes all the elements from the set
Code:
Output:
iii. Copy(): ~Returns a copy of the set
Code:
Output:
iv. Difference(): ~Returns a set containing the difference between
sets
Code:
Output:
v. [Link](): ~ Removes the items in this set that are also
included in another, specified set
Code:
Output:
vi. discard(): ~Removes the specified item
vii.
Code:
Output:
viii. intersection(): ~ Returns a set containing common elements b/w sets
Code:
Output:
ix. intersection update(): ~ removes non similar items
Code:
Output:
x. isdisjoint(): ~ Returns whether two sets have a intersection or not
Code:
Output:
xi. issubset(): ~ Returns whether another set contains this set or not
Code:
Output:
xii. issuperset(): ~ Returns whether this set contains another set or not.
Code:
Output:
xiii. pop(): ~Removes a random element from the set
Code:
Output:
xiv. remove(): ~ Removes the specified element
Code:
Output:
xv. symmetric difference(): ~ Returns a set with the
symmetric differences of two sets
Code:
Output:
xvi. symmetric_difference_update (): ~Inserts the symmetric
differences from this set and another.
Code:
Output:
xvii. union() : ~ Returns a set containing the union of sets
Code:
Output:
xviii. update(): ~ Updates the set with the union of this set and others
Code:
Output: