- 01 - Housekeeping
- 02 - Python the Language
- 03 - Your Engineering System
- 04 - Jupyter Notebooks 101
- 05 - Basic Syntax
- 06 - Data Structures
- 07 - Control Flow
- 08 - Functions
Jupyter notebooks let you mix code, narrative, math, and plots in a single document. That makes them perfect for exploratory work, design calculations, and sharing results with teammates who do not want to trawl through raw Python files.
I start most of my work in a notebook because it allows for easy modularization of code. Once I'm happy with it, I might turn it into a script for automating something or I may keep it as a notebook to document my design process with commentary and notes and outputs, so they are all in one place
I run notebooks inside VS Code, backed by environments managed with uv. Adjust the workflow if you prefer another editor, but the core steps stay the same.
-
Install uv (once per machine):
Invoke-WebRequest -Uri https://astral.sh/uv/install.ps1 -OutFile install.ps1 powershell -ExecutionPolicy Bypass -File .\install.ps1
-
Install Python via uv:
uv python install 3.12 -
Create a project folder and initialise it:
mkdir python-essentials-demo cd python-essentials-demo uv init
This creates a
.venvfolder tied to the project and apyproject.tomlyou can grow into later. -
Add Jupyter tooling inside the environment:
uv pip install ipykernel jupyterlab
ipykernelexposes the environment to notebooks.jupyterlabgives you the CLI tooling even if you work inside VS Code. -
Install the VS Code extensions: "Python" and "Jupyter" by Microsoft.
-
Select the environment:
Ctrl+Shift+P-> "Python: Select Interpreter" -> choose the.venvthat uv created.
Ctrl+Shift+P-> "Jupyter: Create New Blank Notebook"- Set the kernel to your
.venv(top-right of the window) - Name the notebook and save it into the project
You are now ready to run code cells, document your thinking, and version the notebook with Git.
- Code cells run Python (or any supported language) and show the output directly beneath the cell.
- Markdown cells allow headings, bullet lists, equations, images, and explanations. Treat them like the engineering notes that make your math readable.
Common shortcuts (command mode in VS Code notebooks):
| Action | Shortcut |
|---|---|
| Run cell and advance | Shift+Enter |
| Run cell in place | Ctrl+Enter |
| Insert cell above | A |
| Insert cell below | B |
| Delete cell | D D (press D twice) |
| Change to code cell | Y |
| Change to markdown cell | M |
| Save notebook | Ctrl+S |
Markdown quick reference:
# H1 heading
## H2 heading
**Bold text**
_Italic text_
- Bullet list item
1. Numbered iteminline codewraps code snippets in single backticks- Code blocks use triple backticks with language name:
# Python code block
x = 42
print(f"Value: {x}")%matplotlib inline- Renders Matplotlib plots inside the notebook.%timeit expression- Profiles a quick calculation.%lsmagic- Lists every available magic command.%%capture- Runs a cell but suppresses the output (handy when a library is noisy).
Remember the leading % is required. Two percent signs (%%) apply the magic to the entire cell.
-
VS Code export:
File -> Exportthen choose HTML (most reliable). PDF export is hit-or-miss when charts are involved, trust me, I've lost hours trying to debug it. Stick with HTML and attach the file if you need to share. -
GitHub renders
.ipynbfiles directly in the browser. Commit the notebook and share the link. -
nbconvert (optional):
jupyter nbconvert --to html your_notebook.ipynb
You can load the companion notebook at examples/00-jupyter-notebooks-101.ipynb if you want a head start.
-
Warm-up notebook
- Create a new notebook.
- Add a markdown cell with a heading and summary of the task.
- Write a code cell that calculates tributary areas for a simple slab, then plot the loading diagram.
-
Documentation drill
- Re-run the previous calculations but add commentary, section headings, and references to design clauses.
-
Performance check
- Write a small function, then use
%timeitto compare two different approaches.
- Write a small function, then use
- Kernel stuck on "Connecting"? Re-select the interpreter or restart VS Code.
- Library not found? Confirm you installed it with
uv pip installinside the project directory. - Notebook renders strangely on GitHub? Export to HTML and attach the file alongside the notebook.
- Official Jupyter documentation
- VS Code Jupyter docs
- JupyterLab user guide
- Matplotlib inline plotting guide
(c) Flocode, 2025