subset superset disjoint

Solutions on MaxInterview for subset superset disjoint by the best coders in the world

showing results for - "subset superset disjoint"
Jakob
12 Aug 2017
1setA = {1, 2, 3, 4, 5, 6}
2setB = {1, 2, 3}
3
4# subset means all elments of setA in setB
5setA.issubset(setB)  #False
6setB.issubset(setA)  #True
7
8# superset returns true if setA contains all elements from setB
9# than it is superset() but here setB is not superset of setA
10
11setB.issuperset(setA) #False
12setA.issuperset(setB) #True
13
14
15# Disjoints returns true if both sets have a null intersection 
16# means no same elements
17
18setC = {7,8}
19setA.isdisjoint(setB) #False
20setA.isdisjoint(setC) #True
21