.IPYNB
Jupyter notebook
Introduction
An .ipynb file is a Jupyter notebook: a document made of cells, some
holding code and some holding text, with the output of each code cell saved beside it.
The name comes from IPython, the project Jupyter grew out of. Notebooks are mostly used
with Python, but a notebook can use any language that has a Jupyter kernel.
Software
- JupyterLab and Jupyter Notebook (any browser, run locally or on a server)
- Visual Studio Code (Windows, macOS, Linux)
- Google Colab (web)
- PyCharm (Windows, macOS, Linux)
- nbviewer, for reading a notebook online (web)
- GitHub and GitLab, which show notebooks in the browser (web)
Structure
A notebook is a JSON document. The top level has four keys: nbformat and
nbformat_minor, the format version (4 for current notebooks),
metadata, which names the kernel and language, and cells, the
list of cells in order.
Each cell has a cell_type of code, markdown or
raw, its source text and its own metadata. Code cells also keep
an execution_count and a list of outputs: printed text, results,
errors, and rich output such as images, which are stored base64-encoded inside the
JSON.
{
"nbformat": 4,
"nbformat_minor": 5,
"metadata": {
"kernelspec": { "name": "python3", "display_name": "Python 3", "language": "python" }
},
"cells": [
{ "cell_type": "markdown", "id": "a1", "metadata": {}, "source": ["# Sums"] },
{ "cell_type": "code", "id": "b2", "metadata": {}, "execution_count": 1,
"source": ["1 + 1"],
"outputs": [ { "output_type": "execute_result", "execution_count": 1,
"data": { "text/plain": ["2"] }, "metadata": {} } ] }
]
}