Pedagogy: extract comprehensions into standalone notebook under 06_python_advanced/
- Dominant language
- Jupyter Notebook
- Stars
- 12
- Forks
- 76
- PR merge metrics
- No merged PRs in 30d
Description
## Goal
List / dict / set comprehensions are introduced in `00_introduction/30_python_review_2.ipynb` but mixed with closures, `pathlib`, `map` / `filter`, and other functional-programming topics in the same file. Comprehensions are heavily used throughout the rest of NMISP (`[f(x) for x in xs]` patterns appear in every numerical-methods chapter) and deserve a focused, exercise-rich notebook.
## Scope
Create `06_python_advanced/30_comprehensions.ipynb`:
- List comprehension basics: `[f(x) for x in xs]`
- With filter: `[f(x) for x in xs if cond(x)]`
- Nested comprehensions: building 2D structures, flattening
- Dict and set comprehensions
- Generator expressions (brief)
- 4–5 exercises tied to numerical contexts:
- Build a coefficient row vector
- Filter a convergence-history list to only iterations exceeding a tolerance
- Construct a 2D grid of function values
- Build a dict mapping iteration index → residual
Trim the corresponding section from `30_python_review_2.ipynb` once the new notebook is in place (or reduce to a one-line pointer).
## Why
- Comprehensions are a high-leverage Python idiom for numerical code; deserve their own treatment.
- Splitting them out lets `30_python_review_2.ipynb` focus on closures / functional patterns without crowding.
## Acceptance
- [ ] Notebook executes end-to-end.
- [ ] At least 4 exercises with numerical-flavor problems and solution cells.
- [ ] `30_python_review_2.ipynb` no longer duplicates the same teaching.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.