Articles

Jupyter Notebook Tutorial: How to install and use Jupyter Notebook

Jupyter Notebook

Jupyter Notebook is an open-source, interactive web application that allows you to create and share documents containing live code, equations, visualizations, and narrative text. It is widely used in data science, machine learning, and scientific research. In this tutorial, we’ll cover the basics of using Jupyter Notebook.

Notebook Interface

The Jupyter Notebook interface consists of a dashboard and individual notebooks. Notebooks are made up of cells, which can contain code, markdown text, or other content.

1. Install Jupyter

You can install Jupyter Notebook using the following command in your terminal or command prompt.

pip install jupyter

More information on pip, check this article here.

For more detailed installation instructions, refer to the official Jupyter installation guide.

2. Launch Jupyter

After installation, you can launch Jupyter Notebook by running the following command in your terminal or command prompt.

jupyter notebook

This will open a new tab in your web browser with the Jupyter Notebook dashboard.

3. Work with Jupyter Notebooks

Cells

A notebook is a collection of cells. There are two main types of cells: code cells and markdown cells. You can add a new cell by clicking the “+” button on the toolbar.

Running Code

To run a code cell, select it and press Shift + Enter or click the “Run” button in the toolbar. The output will be displayed below the cell.

Markdown Cells

Markdown cells allow you to write formatted text, equations, and documentation using the Markdown language. You can change a cell type to Markdown in the toolbar or by using the keyboard shortcut M in command mode.

4. Keyboard Shortcuts

Command Mode and Edit Mode

  • Press Esc to enter command mode.
  • Press Enter to enter edit mode.

Basic Shortcuts

  • Shift + Enter: Run the selected cell.
  • Ctrl + S: Save the notebook.
  • A: Insert a new cell above the current cell (in command mode).
  • B: Insert a new cell below the current cell (in command mode).
  • D, D (press D twice): Delete the selected cell(s) (in command mode).

For more shortcuts, refer to the Jupyter Notebook documentation.

5. Markdown Basics

Headings

# Heading 1
## Heading 2
### Heading 3

Text Formatting

*italic* or _italic_
**bold** or __bold__

Lists

- Item 1
- Item 2

1. First item
2. Second item

Code Blocks

`` `python
# Python code here
print("Hello, Jupyter!")
`` ``

Links

[Link Alt Text](website_url)

Images

![Image Alt Text](image_url)

6. Commands

Magic commands are special commands that are not a part of the Python language but are recognized by the IPython kernel.

Useful Magic Commands

  • %run script.py: Run an external script.
  • %load file.py: Load the content of a file into a cell.
  • %timeit: Time the execution of a statement.

7. Saving Jupyter Notebooks

Remember to save your work regularly using Ctrl + S. You can export notebooks to various formats, including HTML, PDF, and slides, from the “File” menu.

The Bottom Line

This tutorial covers the basics of using Jupyter Notebook. Explore additional features and functionalities to enhance your data science and programming experience. Happy coding!


by AICorr Team

We are proud to offer our extensive knowledge to you, for free. The AICorr Team puts a lot of effort in researching, testing, and writing the content within the platform (aicorr.com). We hope that you learn and progress forward.