0% found this document useful (0 votes)
6 views6 pages

Sets Assignment

cs assigment

Uploaded by

Momina Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Sets Assignment

cs assigment

Uploaded by

Momina Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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. Diffrence.update(): ~ 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:

You might also like