Ex.
``` my_set = set() my_set = set([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) my_set = set((1, 2, 3, 4, 5, 1, 2, 3, 4, 5)) # my_set = {1, 2, 3, 4, 5} ```
Ex.
``` my_set = set() my_set.add(1) my_set.add(2) my_set.add(3) # my_set = {1, 2, 3} ##################################3 my_set.update({4, 5, 6}) # my_set = {1, 2, 3, 4, 5, 6} ```
Ex.
``` my_set.remove(5) # my_set = {1, 2, 3, 4, 6} ```
Ex.
``` a = {1, 2, 3, 4, 5} b = {3, 4, 5, 6, 7} # 교집합 print(a & b) print(a.intersection(b)) #합집합 print(a | b) print(a.union(b)) #차집합 print(a - b) print(a.difference(b)) ```
ㄴ> 출력 값
``` {3, 4, 5} {3, 4, 5} {1, 2, 3, 4, 5, 6, 7} {1, 2, 3, 4, 5, 6, 7} {1, 2} {1, 2} ```