2Foundational Skills 2.2Jupyter Notebook
2.2.1 Jupyter Notebook Interface and Basics
Work comfortably in a notebook: cells, the kernel, the shortcuts worth knowing, and the mistakes that confuse every beginner.
What is a notebook?
A notebook is a document made of cells, saved in a file ending in .ipynb. We put Python in code cells, run one cell at a time and see each result directly below it. We use Markdown cells for the text around the code: notes, headings and even formulas.
Unlike a normal .py file, a notebook does not make you run everything at once. You can run one cell, look at what happened and decide what to try next. That is exactly how we usually work with data: load it, inspect it, try a model, check the score, change something and try again.
Why notebooks matter for IOAI
Notebooks are not only a convenient place to practise. They are where you will do the contest itself:
- The 2026 contest rules say that a web-based JupyterLab, with GPUs, is the main place where you write and run code during the contest. You open a Jupyter server in the browser, and that becomes your whole workspace: you do not have VS Code, editor extensions or a separate Python installation on the computer in front of you.
- The same document says the at-home round runs on Kaggle, which has its own notebooks.
- Past tasks are published as notebooks too. Open one of the 2026 individual tasks and you will see.
You do not need to become a Jupyter expert. You do need the interface to feel familiar enough that it stays out of your way. Six hours passes quickly when you are fighting cells and shortcuts instead of working on the task.
Where to run notebooks
You have several good places to practise at home. Their buttons look a little different, but the basic ideas on this page work in all of them:
| Option | What you need | Good for |
|---|---|---|
| Try Jupyter | Nothing; it runs in your browser | A first look, right now |
| VS Code | Python and the Python and Jupyter extensions (Setting Up Python) | Working with notebooks alongside your .py files |
| JupyterLab on your computer | Python (Setting Up Python) | Practising in the same interface as the contest |
| Google Colab | A Google account | Working from any computer, and trying GPUs |
| Kaggle Notebooks | A Kaggle account | Kaggle datasets and competitions, and the IOAI at-home round |
If you want JupyterLab on your own computer, run these commands in a terminal. Use python3 instead of python if that is how you normally run Python:
python -m pip install jupyterlab
jupyter lab
JupyterLab will open in your browser. In the Launcher, click Python 3 (ipykernel) under Notebook, and you have your first notebook.
If you set up VS Code in Setting Up Python, you can also make a notebook there. Open a folder in VS Code, create a file ending in .ipynb, and choose your Python environment as the kernel in the top-right. Add a code cell and press Shift+Enter to run it. If VS Code asks to install a Jupyter package for that environment, follow the prompt. The cells and kernel work the same way as in JupyterLab, though some buttons and shortcuts differ.
Running cells
Click a code cell, type some Python and press Shift+Enter. Jupyter runs the cell and moves you to the next one. Use Ctrl+Enter (Cmd+Enter on a Mac) when you want to run the cell but stay where you are.
A code cell automatically shows the value of its last line, so you do not always need print:
x = 21
x * 2
42
Only that last value appears automatically. If you want to see an earlier value too, use print:
print("hello")
x * 2
x + 1
hello
22
Python still worked out x * 2; Jupyter simply did not display it because it was not last. We will use this all the time with data: put a table's name on the final line and Jupyter displays the table for us.
Edit mode, command mode and shortcuts
A notebook has two modes. They can feel odd at first, but the distinction becomes natural after a little use:
- Edit mode: you are typing inside a cell. Select a cell and press Enter to get here.
- Command mode: you are working with the whole cell—adding, deleting or moving it. Press Esc to get here. The cell's border changes colour to show your current mode.
In command mode, a single key can perform an action. These are JupyterLab's defaults, so these are the shortcuts you will have in the contest:
| Key (command mode) | What it does |
|---|---|
A |
Add a cell above |
B |
Add a cell below |
M |
Turn the cell into a Markdown cell |
Y |
Turn the cell into a code cell |
D, D (press twice) |
Delete the cell |
Z |
Undo the last cell action, such as a deletion |
I, I |
Interrupt: stop a cell that is running too long |
0, 0 |
Restart the kernel (see below) |
Do not try to memorise the whole table today. Start with A, B and D, D; the others will stick when you need them. If a shortcut unexpectedly types a letter into your code, press Esc first—you were still in edit mode. Google Colab has its own shortcuts under Tools → Keyboard shortcuts.
Running cells out of order
Behind every notebook is a kernel: the Python process that runs your cells. It remembers every variable we create until we restart it. The number beside a cell, such as [4], tells you when that cell ran.
That memory is useful, but it also causes the most confusing notebook mistakes. Suppose we have two cells:
price = 100
price = price * 2
price
Run the first cell and then the second, and you get 200. Now run only the second cell again:
400
The code on the screen did not change, but price is now 400. The kernel remembered 200 from the previous run and doubled it again. A notebook may be displayed from top to bottom, but its current state depends on which cells you ran, in which order and how many times.
The reverse can happen too. If you restart the kernel with 0, 0 or the Kernel menu, it forgets everything. Run the second cell before the first and you get an error, even though the notebook still looks the same:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[1], line 1
----> 1 price = price * 2
2 price
NameError: name 'price' is not defined
Markdown cells
Press M in command mode to turn a cell into a Markdown cell. Type some text, then press Shift+Enter to format it. You only need a few symbols to keep a notebook readable:
## Plan
- Look at the data
- Try a **baseline** first
Accuracy is $\frac{\text{correct}}{\text{total}}$.
## makes a heading, - makes a bullet, **...** makes text bold, and $...$ displays a formula. You do not need fancy formatting. A few headings such as "Load data", "Baseline" and "Model 2" are enough to make a long contest notebook much easier to navigate. The Markdown Guide lists the rest when you need it.
Handy tricks
- Tab: type part of a name and press Tab to see possible completions. This saves you from remembering long library function names exactly.
- Shift+Tab: place the cursor inside a function's brackets to see which arguments it accepts.
?: put it after a name, such aslen?, and run the cell to read its documentation.%pip install: installs a library into the environment your notebook is actually using. Prefer this topip installin a separate terminal, which may point to a different Python. Restart the kernel afterwards. You will mainly use this at home; contest libraries are already installed and internet access is limited.%timeand%timeit: put one at the start of a line to measure how long it takes. This is useful when a model feels slow and you want an actual measurement.
Lines beginning with % are called magic commands. They work in notebooks, not ordinary .py files. You do not need to learn them all; the IPython documentation is there when you need another one.
Common problems
Most notebook problems are not mysterious Python failures. They usually come from the kernel's state, the selected environment or a cell that is still running. Start with the table below.
| What you see | What it usually means | What to do |
|---|---|---|
NameError: name 'price' is not defined |
The kernel was restarted, or you skipped the cell that makes price |
Run the cells above it, or Restart Kernel and Run All Cells… |
ModuleNotFoundError: No module named 'librosa' |
The library is not installed in this notebook's environment | Run %pip install librosa, then restart the kernel |
A cell shows [*] and never finishes |
It is still running: a long training run, or a loop that never ends | Wait, or interrupt it with I, I or the stop button |
| "The kernel … appears to have died. It will restart automatically." | Usually out of memory, often from loading too much data at once | Restart, then use less data or a smaller model |
| Results that change when you run the notebook again | Cells were run out of order | Restart Kernel and Run All Cells… |
Learn more
You do not need to work through every resource. Choose the format that helps you most:
- Watch: Rob Mulla's Jupyter Notebook Complete Beginner Guide covers Jupyter, JupyterLab, Colab and Kaggle in one video. Corey Schafer's Jupyter Notebook Tutorial uses an older interface, but the ideas still apply.
- Read: use the official tour of the JupyterLab interface and its page on notebooks, or Real Python's Jupyter Notebook: An Introduction.
- Using Colab or Kaggle: keep Colab's Overview of Colab Features or Kaggle's Notebooks documentation nearby.
Try it yourself
The interface becomes familiar by using it, not by memorising a page about it. This short task is enough for a first practice session.
Check yourself
Try these before opening the answers. If you are unsure, run the code in a notebook and watch what changes.
What comes next
Once you can create cells, run the notebook from the top and recover from the common problems above, you know enough Jupyter to move on. The remaining shortcuts will come naturally as we use notebooks in later modules.
- Pandas: load a real dataset into your notebook and explore it.
- Matplotlib: draw charts right below your code.
Resources
| Source | Title | Why read it |
|---|---|---|
| Rob Mulla | Jupyter Notebook Complete Beginner Guide | One video covering Jupyter, JupyterLab, Google Colab and Kaggle. |
| Corey Schafer | Jupyter Notebook Tutorial: Introduction, Setup, and Walkthrough | An older interface, but the ideas and shortcuts are the same. |
| JupyterLab | The JupyterLab Interface | The official tour of the interface IOAI gives you in the contest. |
| JupyterLab | Notebooks | Creating notebooks, edit and command mode, tab completion. |
| Real Python | Jupyter Notebook: An Introduction | A written walkthrough, if you prefer reading. |
| Google Colab | Overview of Colab Features | A notebook about Colab notebooks, if you practise there. |
| Kaggle | Notebooks documentation | How Kaggle's notebooks work, including data and GPUs. |
| IPython | Built-in magic commands | Reference for %pip, %time, %timeit and the rest. |
Finished this module? Mark it done.
Comments
Stuck on something, spotted a mistake, or found a resource that helped you? Tell us below.
Loading comments