Week 3 is where collection algebra becomes your vocabulary. Set operations — intersection, difference, union — turn questions like "what do these two datasets share" into one-liners. Dict merging and inversion turn "combine these configs" and "look up by value instead of key" into single expressions. And zip binds parallel sequences together.
Are sets actually useful day to day, or is this more theoretical?
Anytime you ask "which items are in both lists" or "which items are in A but not B", you want sets. Finding duplicates across datasets, diffing configurations, checking membership across large collections — all set operations. The math maps directly to Python's operators & | -.
And zip and invert — I've seen them but never reached for them. When do they show up?
zip shows up every time you have two parallel lists that should be a dict — headers and values, names and scores. Inverting a dict shows up when you need to look up by value instead of key. Five lessons: find common tags, combine unique items, merge two dicts, build a dict from parallel lists, and invert keys and values.
&|{**a, **b} spread syntaxzip() and dict()Goal: by Friday, set algebra and dict manipulation are one-liners.
7 lessons this week
Week 3 is where collection algebra becomes your vocabulary. Set operations — intersection, difference, union — turn questions like "what do these two datasets share" into one-liners. Dict merging and inversion turn "combine these configs" and "look up by value instead of key" into single expressions. And zip binds parallel sequences together.
Are sets actually useful day to day, or is this more theoretical?
Anytime you ask "which items are in both lists" or "which items are in A but not B", you want sets. Finding duplicates across datasets, diffing configurations, checking membership across large collections — all set operations. The math maps directly to Python's operators & | -.
And zip and invert — I've seen them but never reached for them. When do they show up?
zip shows up every time you have two parallel lists that should be a dict — headers and values, names and scores. Inverting a dict shows up when you need to look up by value instead of key. Five lessons: find common tags, combine unique items, merge two dicts, build a dict from parallel lists, and invert keys and values.
&|{**a, **b} spread syntaxzip() and dict()Goal: by Friday, set algebra and dict manipulation are one-liners.