set comprehensions in addition to creating sets by calling set()or by using set literalwe can also create sets using set comprehensions set comprehension is an expression and loop with an optional condition enclosed in braces like list comprehensionstwo syntaxes are supported{expression for item in iterable{expression for item in iterable if conditionwe can use these to achieve filtering effect (providing the order doesn' matterhere is an examplehtml { for in files if lower(endswith((htm"html"))given list of filenames in filesthis set comprehension makes the set html hold only those filenames that end in htm or htmlregardless of case just like list comprehensionsthe iterable used in set comprehension can itself be set comprehension (or any other kind of comprehension)so quite sophisticated set comprehensions can be created frozen sets | frozen set is set thatonce createdcannot be changed we can of course rebind the variable that refers to frozen set to refer to something elsethough frozen sets can only be created using the frozenset data type called as function with no argumentsfrozenset(returns an empty frozen setwith frozenset argument it returns shallow copy of the argumentand with any other argument it attempts to convert the given object to frozenset it does not accept more than one argument since frozen sets are immutablethey support only those methods and operators that produce result without affecting the frozen set or sets to which they are applied table ( lists all the set methods--frozen sets support frozenset copy()frozenset difference((-)frozenset intersection((&)frozenset isdisjoint()frozenset issubset((<=also for proper subsets)frozenset issuperset((>=also for proper supersets)frozenset union((|)and frozenset symmetric_difference((^)all of which are indicated by in the table if binary operator is used with set and frozen setthe data type of the result is the same as the left-hand operand' data type so if is frozen set and is setf will produce frozen set and will produce set in the case of the =and !operatorsthe order of the operands does not matterand = will produce true if both sets contain the same items shallow and deep copying