- Related Questions & Answers
- Python - Intersection of multiple lists
- Python - Intersection of two String
- The intersection of two arrays in Python (Lambda expression and filter function )
- Intersection of Two Linked Lists in Python
- Intersection of Two Arrays II in Python
- Intersection in Tuple Records Data in Python
- Python program to find Intersection of two lists?
- Intersection of two arrays JavaScript
- Find common elements in three sorted arrays by dictionary intersection in Python
- Program to find linked list intersection from two linked list in Python
- Intersection of two arrays in C#
- Intersection of two arrays in Java
- Intersection of two HashSets in C#
- Character class: intersection - Java regular expressions
- Intersection of Two Arrays in C++

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about intersection() function that can be performed on any given set. According to mathematics intersection means finding out common elements from the two sets.

<set name>.intersection(<set a1> <set a2> ……..)

common elements in sets passed as arguments.

set_1 = {'t','u','t','o','r','i','a','l'} set_2 = {'p','o','i','n','t'} set_3 = {'t','u','t'} #intersection of two sets print("set1 intersection set2 : ", set_1.intersection(set_2)) # intersection of three sets print("set1 intersection set2 intersection set3 :", set_1.intersection(set_2,set_3))

set1 intersection set2 : {'i', 'o', 't'} set1 intersection set2 intersection set3 : {'t'}

Here a search is made to find the common elements by interpreter implicitly and is returned back as a set to the respective reference.

In this article, we learned about the implementation and usage of the intersection function present in Python 3.x. Or earlier.

Advertisements