python adding and subtracting sets

Solutions on MaxInterview for python adding and subtracting sets by the best coders in the world

showing results for - "python adding and subtracting sets"
Domenico
31 Apr 2017
1a = {10,20,30,40}
2b = {30,40,50,60}
3
4
5print(a & b)
6print(a.intersection(b))
7#OUTPUT
8#{30,40}
9
10print(a | b)
11print(a.union(b))
12#OUTPUT
13#{10,20,30,40,50,60}
14
15print(a - b)
16print(a.difference(b))
17#OUTPUT
18#{10,20}
19
20print(b - a)
21print(b.difference(a))
22#OUTPUT
23#{50,60}