12.21 Mini Projects
Four small set-based projects -- a duplicate log analyzer, an inventory comparator, a firewall rule comparator built on …
Four small set-based projects -- a duplicate log analyzer, an inventory comparator, a firewall rule comparator built on …
Practice programs reinforcing Python set concepts -- a duplicate remover, a unique-visitor counter built on len(set(...)), and a package …
Frequently asked and scenario-based Python set interview questions covering set vs. frozenset, why {} is a dict and not a set, hashability, …
When automatic deduplication and mathematical set operations make a set the right choice, why converting a checked-against collection to a …
The most common set bugs -- writing {} and silently getting a dict instead of an empty set, putting an unhashable type like a list into a …
Five places sets are the natural fit in infrastructure code -- deduplicating IP addresses from logs, comparing installed vs. required …
Reading unique values directly into a set with a comprehension over file lines, sorting before writing since sets have no guaranteed order, …
The set-based patterns behind removing duplicates, extracting unique elements, finding common items between two lists, and computing the …
A time-complexity table for the core set operations, why a set uses more memory per element than a list or tuple, and a direct timeit …
The same comprehension syntax as list comprehensions, but with {} instead of [], automatically deduplicating the result -- basic, …
frozenset -- the immutable counterpart to set -- same union/intersection/membership behavior, but no add(), remove(), or update(), which is …
Visiting every element of a set with a for loop and with enumerate() -- and why the indices enumerate() produces are meaningless as …
The same general-purpose sequence functions used with lists and tuples -- len, max, min, sum, sorted, any, all -- work identically on sets, …
Method equivalents of union/intersection/difference/symmetric_difference, plus the relationship-testing methods with no operator form -- …
Union (|), intersection (&), difference (-), and symmetric difference (^) as real mathematical set operations applied directly to Python …
Why s[0] raises TypeError on a set -- elements are located by hash, not by integer position -- and why iteration order is an implementation …
remove() vs discard() -- the same removal, but one raises KeyError on a missing value and the other doesn't -- plus pop()'s …
add() for a single element that silently no-ops on a duplicate, update() for merging in one or more other iterables at once, and how that …
Why a set is a hash table internally -- how hash(element) determines a slot directly, why that's what makes membership testing O(1) average, …
Why an empty set must use set() instead of {}, set literals, the set() constructor's automatic deduplication, and building sets from lists, …
What a set is, its core characteristics, why automatic deduplication and O(1) average membership testing are the entire reason it exists as …