What is a .ipynb file?
A.ipynb file (IPython Notebook) is a JSON document that stores a sequence of cells. Each cell can contain either Python code or Markdown text. When you run a code cell, the output is captured and saved directly in the file alongside the code that produced it.
This structure makes notebooks great for:
- Learning — see what each line does immediately
- Experimentation — try an idea, see the result, adjust and try again
- Documentation — mix explanations with runnable code
- Data analysis — display DataFrames, charts, and statistics inline
Notebook environments compared
There are several places you can run Jupyter notebooks. Here is a quick comparison:
For this course, you will primarily use VS Code Notebooks, since they keep your notebooks and Python files in the same workspace.
Creating a notebook in VS Code
To use notebooks in VS Code you need the Python and Jupyter extensions installed (covered in the Setup page), plus theipykernel package in your active environment.
1
Install notebook support
Open the VS Code terminal and run:
2
Create a new notebook
Use either of these methods:Option A — File menu:Option B — Command Palette:
Press
Ctrl/Cmd + Shift + P, then search for:3
Select a kernel
Click Select Kernel in the top-right corner of the notebook and choose the Python interpreter from your virtual environment.
4
Run your first cell
Click in the first cell, type a Python expression, and press
Shift + Enter to run it.Running code in notebooks
Notebooks support two types of cells: Code cells — contain Python (or shell commands with!):
! to run operating system commands:
%pip (not pip) inside notebooks:
Using
%pip install inside a notebook is preferred over !pip install because %pip ensures the package is installed into the same Python environment the notebook kernel is using.Essential keyboard shortcuts
Notebooks have two modes: Edit mode (you are typing inside a cell) and Command mode (you are navigating between cells). PressEsc to enter Command mode and Enter to return to Edit mode.