Notes / tag / python-foundations

#python-foundations

37 notes

# Data Structures Algorithms

All Data Structures Algorithms notes →

Practice Patterns — Full Source Catalogue 1

The complete pattern-printing drill corpus behind the Pattern Practice & Loops chapter — every triangle, pyramid, rhombus, letter-art, and name-banner function as runnable Python, grouped by shape family.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice Patterns — Full Source Catalogue 2

The complete pattern-printing drill corpus behind the Pattern Practice & Loops chapter — every triangle, pyramid, rhombus, letter-art, and name-banner function as runnable Python, grouped by shape family.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Math & Random

The raw practice snippets behind the Math & Random chapter — a run-and-print tour of the math module (roots, logs, trig, gcd/lcm/factorial) and the random module (uniform draws, sampling, shuffling, seeding).

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: itertools & functools

The raw itertools and functools practice script behind the itertools & functools chapter — one function walks permutations, combinations, product, chain, cycle/count/repeat, accumulate, compress, dropwhile/takewhile, and groupby; the other covers lru_cache memoization, reduce, partial, and wraps.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Python Algorithm Idioms

The raw sort, search, count, group, and filter-map-reduce practice functions behind the Python Algorithm Idioms chapter — five standalone drills demonstrating each pattern before the chapter contrasts hand-rolled versions against their idiomatic standard-library equivalents.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Control Flow

The runnable practice source behind the Control Flow chapter — if/elif/else and nested if, the ternary expression, match/case structural pattern matching, for and while loops with enumerate/zip/dict iteration, break/continue/pass, the loop's else clause, and nested-loop early exit.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Functions

The raw practice source behind the Functions chapter — runnable demonstrations of default/positional-only/keyword-only arguments, *args and **kwargs, lambdas, closures, decorators, and first-class function patterns, including the classic mutable-default-argument trap.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Classes & OOP

The raw practice corpus behind the Classes & OOP chapter — runnable Python covering instance vs. class attributes, classmethods/staticmethods, inheritance, super(), dunder methods, properties, dataclasses, and multiple inheritance/MRO.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Error Handling

The raw practice corpus behind the Error Handling chapter — runnable functions covering try/except basics, multiple except clauses, else/finally, raise and re-raise, custom exception hierarchies, and exception chaining.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Comprehensions

Runnable source behind the Comprehensions chapter — list, nested, dict, set, and generator-expression drills, plus the walrus operator's use inside a comprehension's filter clause.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Generators

The raw practice source behind the Generators chapter — iterator protocol, yield basics, infinite generators via itertools.islice, yield from delegation, two-way communication with send(), lazy pipelines, and a generator-vs-list memory comparison.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Built-in Functions

The raw practice snippets behind the Built-in Functions chapter — sorted()/key=, aggregate reflexes, enumerate/reversed/range/zip, map()/filter(), and the numeric/identity/type-conversion builtins — each demoed with printed output for quick reference.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Strings

The two-function practice script behind the Strings chapter — a quick-reference tour of str's built-in methods (case, search, split/join, format, slicing) and the string module's character-set constants, including the str.maketrans/translate pattern for bulk punctuation removal.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Lists

The raw practice source behind the Lists chapter — creating, accessing, growing, shrinking, iterating, counting, sorting, slicing, copying, and unpacking a Python list, as the original runnable functions grouped by operation.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Tuples

The raw practice source behind the Tuples chapter — tuple immutability, basic operations (concatenation, membership, aggregates), reversing/sorting, shallow vs. deep cloning, and packing/unpacking for multi-value returns, as runnable Python functions.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Dictionaries

The raw practice corpus behind the Dictionaries chapter — creating, reading, updating, removing, sorting, aggregating over values, iterating, copying, and unpacking dicts as keyword arguments, as runnable Python grouped by topic.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice Sets — Full Source Catalogue

The complete set-operations practice corpus behind the Sets chapter — creating, mutating, and iterating sets, subset/superset/disjoint checks, the full union/intersection/difference algebra, and frozensets, as runnable Python grouped by topic.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Practice: Collections Module

The raw practice source behind the Collections Module chapter — runnable demos of defaultdict, Counter, deque, and namedtuple covering initialization, grouping, counting, multiset arithmetic, queue/stack patterns, and named-field records.

data-structures-algorithms python-foundations reference
Aug 3, 2026

Core Data Structures Practice — Full Source Catalogue

The raw practice corpus behind six Part 00 chapters — list, dict, set, tuple, the collections module (deque, Counter, defaultdict, OrderedDict, namedtuple), and heapq/bisect — as runnable Python, grouped by data-structure family instead of write order.

data-structures-algorithms python-foundations reference
Aug 3, 2026

1 — Pattern Practice & Loops

Why 'print a pyramid of stars' is really row-to-bound translation practice — the same instinct a DP table, a matrix traversal, or any 2D grid problem later in this book needs without ever calling it out by name.

data-structures-algorithms python-foundations book
Jul 31, 2026

10 — Math & Random

Python's math module trades general-purpose float arithmetic for a handful of exact, integer-safe helpers, while random trades true unpredictability for a deterministic, seedable stream that only looks random. This chapter is what each module actually guarantees, where those guarantees quietly break, and the worked examples — a perfect-square check, reservoir sampling, Fisher–Yates — that lean on them.

data-structures-algorithms python-foundations book
Jul 31, 2026

11 — itertools & functools

How two small standard-library modules replace hand-rolled nested loops and memoization boilerplate with composable, lazy building blocks — and where reaching for the library instead of writing the loop yourself stops being free.

data-structures-algorithms python-foundations book
Jul 31, 2026

12 — Python Algorithm Idioms

The sort, search, count, group-by, and filter-map-reduce patterns covered elsewhere in this book, restated as a question of expression, not algorithm: given that you already know which pattern a problem wants, what's the Python-idiomatic way to write it, and which hand-rolled version is quietly hiding a bug the standard library already closed.

data-structures-algorithms python-foundations book
Jul 31, 2026

13 — Control Flow

Python hands you six different ways to branch or repeat — if/elif, the ternary, match/case, for, while, and the loop's own often-forgotten else clause — and none of them crash when you pick the wrong one, they just quietly hide what the code is actually deciding.

data-structures-algorithms python-foundations book
Jul 31, 2026

14 — Functions

How Python binds arguments, remembers enclosing scope through closures, and treats every function as a plain object — the mechanics underneath default/keyword arguments, *args/**kwargs, decorators, and the mutable-default trap that catches almost everyone once.

data-structures-algorithms python-foundations book
Jul 31, 2026

15 — Classes & OOP

A Python class bundles state and behavior behind one name and a small set of dunder-method hooks that make instances look and act like built-ins — this chapter is what those hooks buy you, and the two places (a mutable class attribute, an __eq__ without a matching __hash__) where the bundling quietly breaks under you.

data-structures-algorithms python-foundations book
Jul 31, 2026

16 — Error Handling

Exceptions are Python's mechanism for splitting 'the code that notices a failure' from 'the code that decides what to do about it' — this chapter is what that split actually guarantees, the precise rules `except`, `else`, and `finally` run under, and where a custom exception hierarchy and explicit chaining beat a bare `except:` and a silently swallowed traceback.

data-structures-algorithms python-foundations book
Jul 31, 2026

17 — Comprehensions

How a comprehension collapses a loop-and-append into a single expression, the exact point — nesting depth, side effects, an unreadable one-liner — where that collapse stops paying off, and the memory trade a generator expression makes to never build the whole collection at all.

data-structures-algorithms python-foundations book
Jul 31, 2026

18 — Generators

How yield turns a function into a resumable object that produces one value at a time instead of building the whole sequence up front, why that swap is O(1) auxiliary memory instead of O(n), and the narrow set of situations — large or infinite sequences, streaming pipelines — where that actually matters.

data-structures-algorithms python-foundations book
Jul 31, 2026

2 — Built-in Functions

Which built-ins earn a place as pure reflex — sorted with key=, enumerate, zip — versus the situational-but-decisive ones like ord/chr and modular pow, and why an interviewer can tell the difference from across the table.

data-structures-algorithms python-foundations book
Jul 31, 2026

3 — Strings

Python's str ships with a wide method surface — case folding, search, split/join, formatting, slicing — that looks like ordinary array manipulation but hands back a brand-new object every single call, and the string module's character-set constants quietly back half the input-validation code you'll ever write.

data-structures-algorithms python-foundations book
Jul 31, 2026

4 — Lists

How Python's list works as a dynamic array wearing friendly syntax, why an alias is not a copy and a shallow copy is not always deep enough, and the handful of methods that turn 'store some values' into the workhorse structure behind almost every problem in this book.

data-structures-algorithms python-foundations book
Jul 31, 2026

5 — Tuples

Why Python's tuple looks like a read-only list but is really the language's native mechanism for multi-value returns and dict/set keys, where that immutability guarantee quietly stops — the first element that's itself a list — and why 'copying' a tuple by slicing is frequently not a copy at all.

data-structures-algorithms python-foundations book
Jul 31, 2026

6 — Dictionaries

Python's dict is the hash table from the neighboring chapter with a full public API wrapped around it — this is a tour of that surface: creation, safe access, mutation, removal, sorting, aggregation, iteration, copying, and its second job as **kwargs.

data-structures-algorithms python-foundations book
Jul 31, 2026

7 — Sets

Python's set trades away order and duplicates for O(1) average membership and a small algebra of whole-collection operations — union, intersection, difference — that turns 'compare two collections' from a nested loop into one line.

data-structures-algorithms python-foundations book
Jul 31, 2026

8 — Collections Module

Four small, purpose-built fixes for the frictions plain dict and list leave behind: an auto-vivifying dict, a dict specialized for counting, a double-ended queue's API surface, and an immutable tuple with named fields.

data-structures-algorithms python-foundations book
Jul 31, 2026

9 — heapq & bisect

How heapq turns 'always know the current smallest (or largest) item' into O(log n) calls over a plain list, how negation borrows that for max-heap behavior, and how bisect turns 'where does this belong in sorted order' into O(log n) search — plus the one place insort quietly costs more than its name suggests.

data-structures-algorithms python-foundations book
Jul 31, 2026