The main chapters of this book teach by guided invention: you derive each algorithm yourself, one small step at a time, before the concept is named. These 47 exercises are a different mode — drill practice. Each notebook gives you one concrete formula or algorithm and asks you to implement it in Python from scratch. There is no arc or narrative; every notebook stands alone.
When to use these. Work through the five groups in order — Expressions, If/Else, Loops, Functions, Recursion — as you finish the corresponding LBI chapter, or as warm-ups before the ML chapters. The ML themes (gradient descent, entropy, neural networks) preview concepts you will invent in full later; if a problem feels too hard, come back after the relevant chapter.
How each notebook works. Read the problem statement. Fill in the starter
cell wherever you see # TODO. Run the test cell at the bottom — if it
prints All tests passed!, you're done.
Best done after: Chapter 3 (Expressions & Functions)
Each problem is a single Python expression. No loops, no conditionals — just
arithmetic, math.exp, and one or two variables.
Best done after: Chapter 4 (If/Else)
Each problem requires a conditional choice — "A" vs "B", "pure" vs
"mixed", "train" vs "val" vs "test". Threshold-based decisions are
everywhere in ML.
Best done after: Chapter 8 (Loops & Arrays)
Each problem asks you to accumulate a result by looping over a list. The themes run from basic statistics (mean, std dev) up to gradient descent and entropy — you will invent the full versions of those ideas in Chapters 15 and 21.
Best done after: Chapter 3 (Expressions & Functions) and Chapter 8 (Loops & Arrays)
These problems ask you to compose smaller functions into larger ones — the same building-block pattern the book uses throughout. The capstone notebooks (regression pipeline, entropy + information gain, sigmoid + perceptron) are mini-versions of full LBI chapters.
Best done after: Chapter 5 (Recursion)
Each problem has a natural recursive structure: a base case and a case that reduces to a smaller version of itself. The ML themes (learning-rate decay, tree depth) appear in the Gradient Descent and Decision Tree chapters.
Source on GitHub · Back to all chapters
© 2026 CloudxLab. All rights reserved.