Python Sets
A set stores unique items with no guaranteed order. {1, 2, 2, 3} becomes {1, 2, 3}. Membership in is fast on average. Union |, intersection &, difference -. Empty set is set() — {} is an empty dict. That {} trap fails more interviews than the algebra.
frozenset is the immutable version. Use a set when duplicates must disappear: unique emails, unique roll numbers. Don’t use a set when order matters — print order can surprise you.
Python Sets — output — {1, 2, 3}, then union {1,2,3,4}, then intersection {3}.
{1, 2, 2, 3}
│ unique
▼
{1, 2, 3}{} is dict; set() is empty set.