A toy kernel shows the hidden-state trap
Read the comments, predict each printed line, then run it.
A notebook is a document of code cells that share one running Python process, which makes it excellent for exploring data and risky for anything you need to repeat. The workflow is to explore in a notebook, then move the working code into modules with tests, seeds and locked dependencies.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write a function run_in_order(cells) that runs a list of code strings in a fresh shared namespace and returns the namespace.
Write a function sample(seed) that returns five dice rolls from its own seeded generator, and show that equal seeds match.
Write a function to_requirements(reqs) that turns a dict of name to version into sorted pinned lines.
Explain it without notes
What is a kernel, and why does it cause the hidden-state problem?
How do you make a notebook result trustworthy and shareable?
Describe a workflow that takes an experiment from a notebook to production code.
Two data scientists run the same notebook and get different numbers. List the causes you would check, in order.
Expected output
cell 2: price is 100
cell 2 again: 500 -> discounted 450.0
discounted is still 450.0 but price is 50