"

Chapter 1 – Introduction to Python with Zumis

1.1 – How to use Jupyter

How to Use Jupyter

Jupyter Notebook is an environment where you can write and run code. In addition, you can include descriptive text to explain your code. This guide provides an introduction to Jupyter Notebook and covers the basics you need to know to get started.
image

 

What is Jupyter Notebook?

Jupyter Notebook is an open-source web application that allows you to create and share documents containing live code, equations, visualizations, and narrative text. It is a powerful tool for data exploration, data visualization, and data analysis, and it supports over 40 programming languages.

Opening a Jupyter Notebook

When you open Jupyter Notebook, you will see a home screen that displays a list of all your current notebooks. To open a notebook, image

Inside a Jupyter Notebook

When you open a lesson in Jupyter Notebook, you will see cells filled with text and code. The most important tools that you will use are the ones highlighted in the toolbar. A typical Jupyter notebook is divided into cells. Some cells have text, and some cells can run code.
image

Cells

Running code cells

To run a code cell, select it by clicking on it. The cell will be highlighted in blue or green, depending on whether it is in edit mode or not. You can also use the up and down arrow keys to select cells. Once the cell is selected, click the “Run” button in the toolbar or press Shift + Enter.

When you run a code cell, the output of the code will appear below the cell. The number next to the cell will also change from “In[]:” to “In[1]:” and so on, depending on the order in which the cells were executed.

Stopping code cells

Sometimes you need to stop a code cell that is currently running. To do this, click the black square button next to the “Run” button in the toolbar. This will terminate the cell that is running.

If a cell is still running, there will be an asterisk next to the cell’s prompt, like this: “In[*]:”. Avoid trying to run more cells if one is still running.

Adding and deleting cells

To add a new cell, click the “Insert” button in the toolbar and choose whether to insert a cell above or below the current cell.
image

To delete a cell, select it and click the “Delete Cells” option under the “Edit” menu in the toolbar.
image

Locked cells

Some cells in Jupyter notebooks are locked, which means that you cannot edit or delete them. This is common in tutorials and instructional materials to prevent accidental changes.

Notebook Functions

Restarting a Notebook

You can restart a notebook by selecting the “Kernel” tab in the toolbar and choosing “Restart & Clear Output”. This clears all the output from the cells and restarts the notebook.
image

Shutting Down a Notebook

To shut down a notebook, select it and click on the orange “Shutdown” button. Be careful not to delete it by accident!
image