Day-10 || Data Collection-SETS ||


Day-10 || Data Collection-SETS ||

Hello World!!!!!!!!! Welcome Back after a long time, Sorry that I was busy with my FUN. Whats today topic is??? Lastly, I hope I had completed TUPLE, yeap Today we will discuss SET, it is data collection where we can create some data.

Yes, Today we are talking about a Data Collection “SET”. Let’s start with the Definition.


SET is a Unique Unordered Collection of Elements. Here there is no chance of duplication in the Elements Creation of Set: A Set is created by using Curly Braces “{}” Separated by comma “,”.It can have no.of Elements (or) Items, and Data Types like int, float, string, double, etc……
set creation
We have created our first Set Data Collection, Let me tell you a “SECRET” that there are 2 types of Sets are available…
1>SET==> It is an unordered unique collection of elements and “Mutable”[Changable]
2>Frozen Set==> It is an unordered unique collection of elements and “IMMutable”[UNChangable]

NOTE: We should not use Empty Curly braces, It creates as a Dictionary!!!!

Set Methods:


It adds a given element in a set if the element is already present in the set, it doesn’t add.

SYNTAX: set.add(item)


It adds the new elements from a set to the set.

SYNTAX: a.update(b)


It removes randomly an element every time.

SYNTAX: set.pop()


It searches for the user removed element and deletes it.

SYNTAX: set.remove(item)


It searches for the user removed element and deletes it. Otherwise remains calm.

SYNTAX: set.discard(item)


Returns the intersection of the instance set and the set as a new set. In other words, a set will return the elements which are contained in both sets are returned.

SYNTAX: a.intersection(b)  (or)  a&b

Union of sets:

The union is the collection of sets is the set of all distinct elements in the collection. It is one of the fundamental Operation through which sets can be combined and related to each other.

SYNTAX:  a|b


The difference method returns the set difference of two sets.

SYNTAX:  a.difference(b)


It returns true if a set has every element of the other set, if not returns false.

SYNTAX: A.issuperset(B)


It returns True if all elements of a set are present, if all elements of a set are present, if not false. if all the elements of A is present in B.

SYNTAX: A.issubset(B)


This method returns True if 2 sets have a null intersection.

SYNTAX: a.isdisjoint(b)

set Methods

set methods

set methods



Hey, I have missed about Frozen Set, that is the second type of Set. I hope we discussed the definition, let me repeat it again……

Definition Of FrozenSet:

It is a new class that has the characteristics of the set, but its elements can’t be changed. A frozen set can be created by using frozenset().

Frozen set

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.