What is issuperset() method in sets | How to use issuperset() method of sets.

Definition

This method is used to return true if one set contains all the items of another set that is being compared with it. Since it returns a value therefore original set remains unchanged and output is printed using another variable.

Syntax

Variable = A.issuperset(B)

This method takes an argument.

Working

What is issuperset() method in sets

How to use issuperset() method of sets

Code

  1. Set A is being taken
  2. Set B is being taken
  3. issuperset() method is being applied on set A with help of set B.
  4. output is printed inside C

Output

  1. Returns true since A set contains all the items of B set

Note that if there is mismatch of even single item this method will return false.

Interview Questions

  • What is difference between issubset and issuperset method in python?

issubset() method returns true if an entire set is inside some other set or not, whereas issuperset() method returns true if a set contains some other sets entire item. 

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 *