How to do a lab
Five minutes, with pictures. Everything runs in your browser: nothing to install.
Each lab is a notebook: a page that mixes short instructions with small pieces of Python code that you run, change and finish yourself. It runs inside your web browser, on the course website. Labs are practice: not graded, nothing to submit.
1 · Open the lab
On the lab’s page, click ▶︎ Start this lab in your browser. The first time, wait 10 to 20 seconds while Python loads into your browser.
{fig-alt=“A JupyterLite window: the file list on the left with the lab notebooks, the Lab 1 notebook on the right, starting with a folded”About this lab” box and the story of the lab”}
- Left: your files. Right: the notebook.
- The notebook is made of cells: text cells (instructions) and code cells (grey boxes).
- Use a computer, with Chrome, Edge or Firefox. A phone is too small.
2 · Run the cells, from the top
Click a code cell, then press Shift + Enter. The cell runs and the next one is selected. (Or click ▶ in the toolbar.)
[ ]not run yet ·[*]running ·[5]done.- Always run the cells in order, from the top. Later cells use what earlier cells made.

3 · Three levels
Every task’s title shows its level, in hot peppers: the more peppers, the spicier.
- 🌶 Core: done together in class. Everyone does these.
- 🌶🌶 Extend: optional, at home, with hints.
- 🌶🌶🌶 Challenge: optional, open-ended, for the curious.
4 · Your turn: finish the code
Where it says Do:, there is a code cell with a line # YOUR CODE HERE. Replace that line with your code.

- Keep the function’s name and inputs: later cells call it by that name.
- The text in triple quotes (the docstring) says exactly what the function must return.
5 · Check your work
The cell right after each function checks it. Run it.
checks passedmeans you are on track.- A red box means not yet. Read the last line: it says what is wrong.

6 · Try other numbers
Many Core cells have their numbers on the first line, marked # try other values. Change them and run the cell again, with the check below it: the best way to see what a model does.
- Change the first line, for example
n_cars, C_a, C_b = 10, 0.36, 0.85. - Run that cell, and its check below.

7 · Where your work is kept
Your work is saved in this browser, on this computer.
- Come back on the same computer and the same browser, and your code is still there. But Python starts fresh: run the cells again from the top (Run → Run All Cells; it stops at the first check that fails).
- Moving to another computer: File → Download, then upload the file there with the upload arrow above the file list.
- Do not work in a private or incognito window: everything is lost when it closes.
- Clearing your browser’s data deletes your work. Download a copy first.

When something goes wrong
| What you see | What to do |
|---|---|
NameError: name 'np' is not defined (or another name) |
You skipped cells. Run → Run All Above Selected Cell, then try again. |
A cell stays at [*] |
Kernel → Restart Kernel, then Run → Run All Above Selected Cell. |
complete ... first |
Finish the function in the cell above. |
| Run All Cells stops halfway | It stopped at a check that fails: read its last line. |
| The page stays blank | Reload the page. Use Chrome, Edge or Firefox on a computer. |
| My work is gone | It lives in the browser you used. Open the lab in that same browser on the same computer. |
Still stuck? Ask in class, or email the instructor with the lab number and a screenshot.