Skip to content

What is a Jupyter Notebook?

What is a Jupyter Notebook?

A Jupyter notebook is an electronic file that contains both programming code and text descriptions. Jupyter notebooks can also contain embedded charts, plots, images, videos, and links. Jupyter notebooks run in a web browser like Firefox or Google Chrome. Although Jupyter notebooks can contain the code of many different programming languages, many Jupyter notebooks contain Python code. The Python code in a Jupyter notebook is the same type of Python code found in a .py file.

The text description sections of Jupyter notebooks contain explanations and clarifications of the programming code in the markdown format. Markdown files have the extension .md. Markdown sections of a Jupyter notebook can include formatting to make text bold, italic, form tables and lists, show code listings and render images. One way to think of a Jupyter notebook is as a combination of the Python REPL and a Python module .py file with a markdown .md file thrown in between code sections.

In the Python REPL, only one command can be typed at a time, and only one line of output is shown at a time. In a .py file, the entire file is run at one time, line by line. The output of the entire file is produced all at once. Markdown .md files contain text in markdown format, but that text is not rendered. In a Jupyter notebook, chunks of code one line or many lines long can be run individually and in any order without running all of the code in the Jupyter notebook. Jupyter notebooks render the markdown sections and display rich text with headings, formatting, and images. Jupyter notebooks contain three types of cells: code cells, output cells, and markdown cells.

  • Code cells: Lines of Python code are run in code cells.

  • Output cells: The output from running the code cells is also shown in output cells. Charts, plots, command line output, and images can all be shown in Jupyter notebooks as well.

  • Markdown cells: Contain text-like descriptions of what will happens in subsequent code cells. Markdown cells can also contain images and links.