issuperset() function in python by R4R Team

- issuperset() is a python function which is only applicable on sets data type.
- it compare two sets and check whether one set is superset of another set or not.
- superset() and issuperset() both are of complimentry nature.

Syntax-

set1.issuperset(set2)

- It will return True, if set2 is superset of set1, i.e. set1 is subset of set2.
- It will return False, if set2 is not superset of set1.

Example

set1 is {1,2}
set2 is {1,2,3,4}

set2.issuperset(set1) will give True
set1.issuperset(set2) will give False.



program-

set1={1,2,3,4}
set2={1,2,3,4,5,6,7,8,9}

print("Set1 is",set1)
print("Set2 is",set2)

print(set1.issuperset(set2))
print(set2.issuperset(set1))


output-

Set1 is {1, 2, 3, 4}
Set2 is {1, 2, 3, 4, 5, 6, 7, 8, 9}
False
True


-In this program, we have two set shown in above program, set2.issuperset(set1) will give True value. beacuse set2 is superset of set1, i.e. set1 is subset of set2.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!