# Internal working of Set in Python

PythonServer Side ProgrammingProgramming

In this article, we will learn about the Internal working of Set in Python. We will observe the union and intersection operation in different frames and objects.

Let’s declare an empty set.

>>> s=set()

Now let’s declare a set with elements.

>>> s1=set('tutorialspoint')

Adding an element into an empty set.

>>> s.add(‘p’)

Now we declare another set with the name of Python.

>>> s2=set('python')

Now let’s see the union operation.

>>> s3=s1.union(s2)

Finally, we implement the intersection option.

>>> s4=s1.intersection(s2)