s={1,2,2,2,3,4,5,5}
print(s,type(s))#輸出{1, 2, 3, 4, 5} <class 'set'>
s1=set(range(6))
print(s1,type(s1))#輸出{0, 1, 2, 3, 4, 5} <class 'set'>
s2=set([1,2,2,2,4,5])
print(s2,type(s2))#輸出{1, 2, 4, 5} <class 'set'>
s3=set('python')
print(s3,type(s3))#輸出{'h', 'n', 'y', 't', 'o', 'p'} <class 'set'>
s4=set()
print(s4,type(s4))#輸出set() <class 'set'>
s4.add(33)
print(s4,type(s4))#輸出{33} <class 'set'>
s4.update({200,3,3})
print(s4,type(s4))#輸出{200, 33, 3} <class 'set'>
s4.update([100,31,32])
print(s4,type(s4))#輸出{32, 33, 3, 100, 200, 31} <class 'set'>
s4.remove(100)
print(s4,type(s4))#輸出{32, 33, 3, 200, 31} <class 'set'>
'''兩個集合是否相等(元素相同就相等)'''
s5={1,2,3,4}
s6={4,2,3,1}
print(s5==s6)#True
print(s5!=s6)#False
'''一個集合是否是另外一個集合的子集'''
s7={10,20,30,40,50,60,70}
s8={10,20,30,40}
s9={10,20,90}
s10={100,200,900}
print(s8.issubset(s7))#True
print(s9.issubset(s7))#False
print(s7.issuperset(s8))#True
print(s7.issuperset(s9))#False
print(s8.isdisjoint(s9))#False,有交集就是false
print(s8.isdisjoint(s10))#True,無交集就是true
print(s8.intersection(s7))#輸出{40, 10, 20, 30},求交集操作
print(s8 & s7)#輸出{40, 10, 20, 30}
print(s9.union(s10))#輸出{20, 90, 900, 100, 200, 10},求並集操作
print(s9 | s10)#輸出{20, 90, 900, 100, 200, 10}