issuperset() in Python
Python set issuperset() method returns True if all elements of a set A occupies set B which is passed as an argument and returns false if all elements of B are not present in A. This means if A is a superset of B then it returns true; else False
Python issuperset() Syntax:
A.issuperset(B) checks whether A is a superset of B or not.
Python issuperset() Returns:
True if A is a superset of B; otherwise false.
Python issuperset() example
Example 1: Working of issubset() with two sets
Python
# Python program to demonstrate working of # issuperset(). A = { 4 , 1 , 3 , 5 } B = { 6 , 0 , 4 , 1 , 5 , 0 , 3 , 5 } print ( "A.issuperset(B) : " , A.issuperset(B)) # B is superset of A print ( "B.issuperset(A) : " , B.issuperset(A)) |
Output:
A.issuperset(B) : False B.issuperset(A) : True
Example 2: Working of issubset() with three sets
Python
# Python program to demonstrate working # of issuperset(). A = { 1 , 2 , 3 } B = { 1 , 2 , 3 , 4 , 5 } C = { 1 , 2 , 4 , 5 } print ( "A.issuperset(B) : " , A.issuperset(B)) print ( "B.issuperset(A) : " , B.issuperset(A)) print ( "A.issuperset(C) : " , A.issuperset(C)) print ( "C.issuperset(B) : " , C.issuperset(B)) |
Output:
A.issuperset(B) : False B.issuperset(A) : True A.issuperset(C) : False C.issuperset(B) : False