0% found this document useful (0 votes)
36 views

How To Use Jupyter Notebooks - Codecademy

Jupyter Notebooks allow users to write and run code interactively in cells, with the ability to re-run cells and edit code. To use a Jupyter Notebook, first install the software and open a terminal to launch the notebook interface with the jupyter notebook command. This interface displays files in the current directory, where new notebooks can be created or existing ones opened. Code is run by selecting cells and pressing shift-enter, with output displayed below. Cells can also contain markdown for documentation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

How To Use Jupyter Notebooks - Codecademy

Jupyter Notebooks allow users to write and run code interactively in cells, with the ability to re-run cells and edit code. To use a Jupyter Notebook, first install the software and open a terminal to launch the notebook interface with the jupyter notebook command. This interface displays files in the current directory, where new notebooks can be created or existing ones opened. Code is run by selecting cells and pressing shift-enter, with output displayed below. Cells can also contain markdown for documentation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

Log In Sign Up

Article Categories →

Codecademy Team

How to Use Jupyter Notebooks


Share

Learn about Jupyter Notebooks and how to use them to run your code in this Jupyter
Notebook Tutorial.

What is Jupyter Notebook?


Jupyter Notebooks are a powerful way to write and iterate on your Python code for data analysis.
Rather than writing and re-writing an entire program, you can write lines of code and run them one
at a time. Then, if you need to make a change, you can go back and make your edit and rerun the
program again, all in the same window.

Jupyter Notebook (formerly known as IPython Notebook) is an interactive way of running Python
code in the terminal using the REPL model (Read-Eval-Print-Loop). The IPython Kernel runs the
computations and communicates with the Jupyter Notebook front-end interface. It also allows
Jupyter Notebook to support multiple languages. Jupyter Notebooks extend IPython through
additional features, like storing your code and output and allowing you to keep markdown notes.

If you haven’t already, install Jupyter Notebook on your computer before reading the rest of the
article. If you’d rather watch a video instead of read an article, please watch the following
instructions on how to use a Jupyter Notebook. They cover the same information.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 1/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

Jupyter Notebook

How to open Jupyter Notebook


To launch a Jupyter notebook, open your terminal and navigate to the directory where you would
like to save your notebook. Then type the command jupyter notebook and the program will instantiate
a local server at localhost:8888 (or another specified port).

A browser window should immediately pop up with the Jupyter Notebook interface, otherwise, you
can use the address it gives you. The notebooks have a unique token since the software uses pre-
built Docker containers to put notebooks on their own unique path. To stop the server and
shutdown the kernel from the terminal, hit control-C twice.

Jupyter Interface
Now you’re in the Jupyter Notebook interface, and you can see all of the files in your current
directory. All Jupyter Notebooks are identifiable by the notebook icon next to their name. If you
already have a Jupyter Notebook in your current directory that you want to view, find it in your files
list and click it to open.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 2/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

To create a new notebook, go to New and select Notebook - Python 2. If you have other Jupyter
Notebooks on your system that you want to use, you can click Upload and navigate to that particular
file.

Notebooks currently running will have a green icon, while non-running ones will be grey. To find all
currently running notebooks, click on the Running tab to see a list.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 3/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

Inside the Notebook


When you open a new Jupyter notebook, you’ll notice that it contains a cell.

Cells are how notebooks are structured and are the areas where you write your code. To run a piece
of code, click on the cell to select it, then press SHIFT+ENTER or press the play button in the
toolbar above. Additionally, the Cell dropdown menu has several options to run cells, including
running one cell at a time or to run all cells at once.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 4/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

After your run a cell, the output of the cell’s code will appear in the space below. To stop running a
piece of code, press the stop button.

To create new cells, use the plus (+) button in the toolbar or hit SHIFT+ENTER on the last cell in the
Notebook. To cut, copy, delete or just generally edit cells - select the cell you want to modify and go
to the Edit button in the navigation bar to see your options.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 5/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 6/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

In addition to running lines of code, you can also include text-only cells that use Markdown to
format and organize your notebooks.

When you create a new cell, it will default to being a Code cell. To create a cell that uses markdown,
click on the Cell menu from the navigation bar, scroll down to Cell Type and choose Markdown.

Occasionally, you might need to restart the kernel. Head to the Kernel dropdown and hit Restart. To
shut down a kernel, you can click Shutdown, which will have a dialogue process asking if that’s what
you would like to do. To force an immediate shutdown, go to the File dropdown and click Close and

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 7/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

Halt and the browser window will close itself. Restarting and shutting down kernels will affect your
variables, so be careful.

In the Help dropdown, you’ll find useful information such as keyboard shortcuts as well as links to
different documentation for modules such as Numpy, SciPy, and Matplotlib.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 8/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

The toolbar has several shortcut buttons for popular actions. From left to right: save, add a new cell,
cut selected cells, copy selected cells, paste cells below, move selected cells up, move selected cells
down, run, interrupt the kernel, restart the kernel, a dropdown that allows you to change the cell
type, and a shortcut to open the command palette.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 9/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

Jupyter Notebook files are saved as you go. They will exist in your directory as a JSON file with the
extension .ipynb . You can also export Jupyter Notebooks in other formats, such as HTML. To do so,
go to the File menu, scroll down to Download as and select the type of file you’re looking for. A
popup will appear asking where you would like this new file to download. Once you’ve navigated to
the appropriate directory, click Save and Checkpoint.

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 10/11
4/27/23, 8:18 AM How to Use Jupyter Notebooks | Codecademy

SUMMARY
As we’ve seen, Jupyter Notebook files are very useful. Its interface allows you to navigate using your
mouse with dropdown menus and buttons, or by keyboard shortcuts. They allow you to run small
segments of code at a time, save them in their current state, or restart and have them return to their
original state. In addition to running code, we can also use markdown to neatly organize our
notebooks so they are presentable to others.

If you’re interested in learning more about Jupyter Notebooks, read their documentation. To try out
a notebook in your browser, go to https://try.jupyter.org/.

Share

Learn More on Codecademy

Skill path

Code Foundations
Start your programming journey with an introduction to the world of code and basic concepts.

Includes 5 Courses

With Certificate

Beginner Friendly 15 Lessons

Career path

Full-Stack Engineer
A full-stack engineer can get a project done from start to finish, back-end to front-end.

Includes 51 Courses

With Professional Certification

Beginner Friendly 169 Lessons

https://www.codecademy.com/article/how-to-use-jupyter-notebooks 11/11

You might also like