###########################################################
# 1、1) Define a collection ( Non repetitive sequences , disorder )
class_num = {1, 2, 3, 4, 5}
# print(class_num)
# 2) Collections are sometimes used to eliminate duplicate elements of lists and tuples
# class_list = [1, 2, 3, 3, 4, 1]
# nums = set(class_list)
# print(nums)
# class_tuple = ('datian', 'lily', 'developer', 'tester', 'datian')
# print(set(class_tuple))
# 3) Set to list、 Or tuple
# print(list(class_num))
# print(tuple(class_num))
# Running results :[1, 2, 3, 4, 5]
# (1, 2, 3, 4, 5)
# 2、 Ergodic set , Same as list operation
# for i in class_num:
# print(i)
# 3、 View collection length
# print("class_num The length of :",len(class_num))
# 4、 Determine whether the set contains an element ?in The operator
print(10 in class_num)
# 5、 Add elements 10,add function , We need to pay attention to :add When adding elements, you will determine whether the new elements are included , If it exists, it will do nothing
# class_num.add(10)
# print(class_num)
# print(10 in class_num)
# 6、 The added element cannot be modified , Delete only remove
# class_num.remove(1)
# print(class_num)
# class_num.remove(1)# Deleting again will result in an error , because 1 This element is no longer in this collection ,
# print(class_num)
# Introduce another delete element discard, Without this element , Do nothing
# class_num.discard(1)
# print(class_num)
# Delete an element from the collection , And return this value , use pop function , This function can be executed all the time , Until empty
# num = class_num.pop()
# print(class_num, num) # Running results :{2, 3, 4, 5} 1
# Cycle through element values
# while class_num:
# num = class_num.pop()
# print(num)
###########################################################
# 2、 Set function
# Find the intersection
s1 = {1,2,4,5}
s2 = {2,5,6}
print(s1.intersection(s2))
# Union
print(s1.union(s2))
# Determine whether a set is a subset of another set
s3 = s1.intersection(s2)
print(s3.issubset(s1))
# Determine whether it is a parent set
print(s3.issubset(s1))