Unique collections and concise data structure creation
Sets are unordered collections of unique elements. They are created with curly braces {} (like dictionaries but without key-value pairs) or the set() constructor. Sets support mathematical set operations like union (|), intersection (&), difference (-), and symmetric difference (^). They are efficient for membership testing (in operator) and eliminating duplicates from sequences. Sets are mutable, but there's also a frozenset type that's immutable. Comprehensions are concise syntax for creating lists, dictionaries, and sets from existing iterables. List comprehensions use [expression for item in iterable], dictionary comprehensions use {key: value for item in iterable}, and set comprehensions use {expression for item in iterable}. Comprehensions can include conditions with if clauses. They provide a more readable and often more efficient way to create data structures compared to traditional loops. Understanding sets and comprehensions allows you to write more expressive and efficient Python code.