Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python Frozenset operations

# Frozensets
# initialize A , B
 and C
A = frozenset([4, 3, 2, 1])
B = frozenset([7, 6, 5, 4])
C = frozenset([5, 4])

# copy
D = A.copy()
print("Copy of frozen set: ", D)

# union
print("Union of frozen set: ", A.union(B)) 

# intersection
print("Intersection of frozen set: ", A.intersection(B)) 

# difference
print("Difference of frozen set: ", A.difference(B))  

# symmetric_difference
print("symmetric_difference of frozen set: ", A.symmetric_difference(B))  

# isdisjoint() method
print("disjoint of frozen set: ", A.isdisjoint(C))

# issubset() method
print("subset of frozen set: ", C.issubset(B))
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #Frozenset #operations
ADD COMMENT
Topic
Name
7+9 =