What is Jupyter Notebook?

A Jupyter notebook is a web application that allows the user to write codes and rich text elements. Inside the Notebooks, you can write paragraph, equations, title, add links, figures and so on. A notebook is useful to share interactive algorithms with your audience by focusing on teaching or demonstrating a technique. Jupyter Notebook is also a convenient way to run data analysis.

Jupyter Notebook App

The Jupyter Notebook App is the interface where you can write your scripts and codes through your web browser. The app can be used locally, meaning you don't need internet access, or a remote server.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt1.webp

Each computation is done via a kernel. A new kernel is created each time you launch a Jupyter Notebook.

How to use Jupyter

In the session below, you will learn how to use Jupyter Notebook. You will write a simple line of code to get familiar with the environment of Jupyter.

Step 1) You add a folder inside the working directory that will contains all the notebooks you will create during the tutorials about TensorFlow.

Open the Terminal and write

mkdir jupyter_tf

jupyter notebook

Code Explanation

https://www.guru99.com/images/1/080418_1223_WhatisJupyt2.webp

Step 2) You can see the new folder inside the environment. Click on the folder jupyter_tf.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt3.webp

Step 3) Inside this folder, you will create your first notebook. Click on the button New and Python 3.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt4.webp

Step 4) You are inside the Jupyter environment. So far, your notebook is called Untiltled.ipynb. This is the default name given by Jupyter. Let's rename it by clicking on File and Rename

https://www.guru99.com/images/1/080418_1223_WhatisJupyt5.webp

You can rename it Introduction_jupyter

https://www.guru99.com/images/1/080418_1223_WhatisJupyt6.webp

In Jupyter Notebook, you write codes, annotation or text inside the cells.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt7.webp

Inside a cell, you can write a single line of code.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt8.webp

or multiple lines. Jupyter reads the code one line after another.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt9.webp

For instance, if you write following code inside a cell.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt10.webp

It will produce this output.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt11.webp

Step 5) You are ready to write your first line of code. You can notice the cell have two colors. The green color mean you are in the editing mode.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt12.webp

The blue color, however, indicates you are in executing mode.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt13.webp

You first line of code will be to print Guru99!. Inside the cell, you can write

print("Guru99!")

There are two ways to run a code in Jupyter:

To run the code, you can click on Cell and then Run Cells and Select Below

https://www.guru99.com/images/1/080418_1223_WhatisJupyt14.webp

You can see the code is printed below the cell and a new cell has appeared right after the output.

https://www.guru99.com/images/1/080418_1223_WhatisJupyt15.webp

A faster way to run a code is to use the Keyboard Shortcuts. To access the Keyboard Shortcuts, go to Help and Keyboard Shortcuts

https://www.guru99.com/images/1/080418_1223_WhatisJupyt16.webp

Below the list of shortcuts for a MacOS keyboard. You can edit the shortcuts in the editor.