Relational calculation methods of the Set, and relational calculation methods of the Set
A = [4, 5, 6, 7, 8]
A = set ()
# A. add ('adfaaaa') # add as only one element
# A. update ([121212]) # It must be an iterative object to add
# Print ()
B = {1, 2, 3, 4, 5}
# Print the total elements at the intersection of the Set
Print (a. intersection (B) # method 1
Print (a & B) # method 2
{4, 5}
# Print out all the elements of the Two Sets and remove duplicates from the union of the Set
Print (a. union (B) # method 1
Print (a | B) # method 2
{1, 2, 3, 4, 5, 6, 7, 8}
# The difference set of the Set uses a as the reference object to find the elements that a does not have B
Print (a. difference (B) # method 1
Print (a-B) # method 2
{8, 6, 7}
# Find out the elements of a and B in the inverse difference set of the set.
Print (a. effecric_difference (B) # method 1
Print (a ^ B) # method 2
{1, 2, 3, 6, 7, 8}
# The parent set of the set only returns True or False to determine whether a is a B's parent set, that is, whether all element a of B has an element a and B does not.
Print (a. issuperset (B) # method 1
Print (a> B) # method 2
False
# The subset of the set determines whether a is a B's sub-set, that is, whether all elements B of a have, and B has elements that a does not have.
Print (a. issubset (B) # method 1
Print (a <B) # method 2
False