This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 4: Jupyter Notebook

Using Jupyter Notebook

face Josiah Wang

There are 2 main items in a Jupyter Notebook:

  • cells which are containers for text to be displayed in the notebook or code to be executed by the notebook’s kernel
  • the kernel that executes the code contained in a notebook document

Cells

A Code cell contains code to be executed in the kernel and displays its output below.

A Markdown cell contains text formatted using Markdown and displays its output in-place when it is run. This is useful for typing text and explanations.

You can tell the difference between Code and Markdown cells because Code cells have the label "In" on the left whereas Markdown cells do not.

You can set the cell type using the toolbar with Cell > Cell Type.

Kernels

A kernel is basically the Python installation/virtual environment that you want to use to execute codes in your notebook.

So a Jupyter notebook is like running an interactive Python session, but more powerful.

The kernel’s state persists over time and between cells. If you import libraries or declare variables in one cell, they will be available in other cells. When you run a Code cell, the label to its left changes from In [ ] to In [1] (or any number in the execution sequence).

Over to you!

That is as far as we will cover for Jupyter Notebooks itself. Use the Help menu item in its toolbar for more advanced help. Just play around and experiment for yourself to see how it works and whether it suits your needs. I’m sure you can handle it on your own! 🙂