What is intersection method in sets | How to use intersection method of sets.

Definition:

This method is used to return a set which has common items in them, if there are no common items it returns an empty set.

What is set in python?

Also, this method can take multiple sets as argument, meaning we can find intersection of n numbers of sets with this method. 

Syntax:

For two set intersection

Variable = A.intersection(B)

 

For two or more set intersection

Variable = A.intersection(B,C,D,E)

This method takes an arguments

Working

What is set in python?

output

Code

  1. Set A is taken
  2. Set B is taken
  3. intersection() method is applied on set A with B
  4. output is taken into third variable
  5. output is printed

Output

  1. The common item from intersection of set A and B is printed

Quick Links

Waqar Khan

Hello, everyone, I am Waqar Khan. I have done my B.tech in Computer Science. I love to write about Computer Informational blogs. Before write I did proper research on it. Hope you like our blogs. Thank you.

Related Posts

Leave a Reply

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