Jupyter Notebook
A Jupyter notebook is a document made of cells. A code cell holds code that a kernel, a separate process such as the Python kernel, executes; its output appears below the cell. A Markdown cell holds formatted text such as headings, lists, tables, and equations that explain the analysis. The notebook file, with the .ipynb extension, stores the cells and, unless they are cleared, the outputs from earlier runs. Jupyter Notebook and JupyterLab are browser-based applications for editing and running these documents.
The kernel keeps names and values in memory between cells. A cell’s result therefore depends on which cells the kernel has already run, not on the cell’s position on the page. The number shown beside a code cell, such as [7], records an execution count. Within one kernel session it helps order recent runs, but saved counts can remain from previous sessions. Editing a cell changes nothing until the cell is run, and deleting a cell does not remove values it has already created.
For example, one cell sets tax_rate = 0.1 and a later cell computes a total. If you change the first cell to 0.2 but do not run it, the total still uses 0.1. If a later cell reassigns tax_rate to 0.3, rerunning the edited first cell sets it to 0.2, the value currently written there. Results that look correct can depend on an order of runs that nobody recorded.
Before sharing results, restart the kernel and run all cells from top to bottom. A clean run helps uncover dependencies on hidden in-memory state; it does not validate the analysis or guarantee the same result with different data or package versions. Saved outputs are records of an earlier run, not evidence that the current code still produces them. Notebooks suit exploration, teaching, and reports. Code that must run unattended on a schedule is usually moved into scripts or packages with tests.
Reference: Project Jupyter Documentation. See it in use in Python Foundations: Variables, Types, and the Notebook.
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
