Skip to main content
HomeAbout PythonLearn Python

How to Use Jupyter Notebooks: The Ultimate Guide

This article covers what Notebooks are and why you should use them. We also delve into hosted notebooks, which facilitate sharing and collaboration. This article also covers tips, tricks, and keyboard shortcuts.
Updated Mar 2023  · 25 min read

Jupyter and the notebook

Jupyter notebooks are documents for technical and data science content. This tutorial provides an overview of Jupyter notebooks, their components, and how to use them. 

We will explore notebooks using Datacamp Workspace, a hosted notebook service that provides all the functionality of Jupyter notebooks, along with functionality for connecting to databases, real-time collaboration, and publishing your work. 

This tutorial assumes that you have used a data science programming language before, such as Python, SQL, R, or Julia.

Overview of notebooks

Notebooks combine computer code (such as Python, SQL, or R), the output from running the code, and rich text elements (formatting, tables, figures, equations, links, etc.) in a single document. 

The key benefit of notebooks is the ability to include commentary with your code. That means that you can avoid the error-prone process of copying and pasting analysis results into a separate report. Instead, you simply mix your analysis with the report text in the notebook.

Who should use Jupyter Notebooks?

Jupyter Notebooks are primarily used by data professionals, particularly data analysts and data scientists. According to the Kaggle Survey 2022 results, Jupyter Notebooks are the most popular data science IDE, used by over 80% of respondents. 

Types of Jupyter Notebook

There are two main types of Jupyter Notebook; hosted and local notebooks. DataCamp provides DataCamp Workspace, a hosted Jupyter Notebook that we will use for the majority of this tutorial. Workspace is an excellent option for learners and professionals who do not want to set up a local environment. 

Except where noted, the functionality described in this tutorial will work on other Jupyter notebook versions. If you prefer to use a local environment, you can install Jupyter Notebook on your machine using our Installing Jupyter Notebook tutorial. Marcus Schanta maintains a list of other hosted notebook platforms.

Components of a notebook

A Jupyter Notebook consists of three main components: cells, a runtime environment, and a file system.

 Cells are the individual units of the notebook, and they can contain either text or code:

  • Text cells are used to write narrative text and include images, links, and equations.
    • Text cells are written in Markdown, a simple markup language.
  • Code cells are used to write and execute code. 
    • The output from code cells will be displayed directly below the code cell. 
  • SQL cells (Workspace only) are used to execute SQL queries, which means you can easily retrieve data from a database.
  • Chart cells (Workspace only) can be used to create visualizations and quickly visualize Pandas dataframes.

The runtime environment is responsible for executing the code in the notebook. The runtime environment can be configured to support different languages, including Python, R or SQL.

The filesystem allows you to upload, store, and download data files, code files, and outputs from your analysis.

Command mode and edit mode

Jupyter notebooks have two different modes of interaction: command mode and edit mode. In command mode, you can navigate between cells, add and delete cells, and change the cell type. In edit mode, you can edit the contents of a cell.

In order to enter command mode, you can either press Escape or click outside a cell. To enter edit mode, you can press Enter or click inside a cell.

In Workspace, you can click the ‘Add Text’ or ‘Add Code’ buttons to add a new cell.


Getting help

For Jupyter notebook, you can get help using the documentation or using the option in the menu. In Workspace, help and keyboard shortcuts can be quickly accessed by pressing the help button in the menu.


Writing text

Text cells are written in the Markdown markup language, allowing you to easily write and format text. While in edit mode, you can use syntax such as ** ** for bold, or use the buttons, to format your text. 

Here are a few different options:


Pressing shift + enter or the ‘View’ button will run the cell, giving the following result.


  • Lines beginning # are a top-level header. Start with ## for a second-level header, ### for a third-level header, and so on.
  • Surround text in ** to make it bold, __ to make it italic, and ` to make it code formatted.
  • Start consecutive lines with - to make them into a bulleted list.
  • Start lines with numbers followed by a period to make them into a numbered list.
  • Hyperlinks are written in two parts. The text to display is surrounded by square brackets, then the url is surrounded by parentheses.

Writing and running code

Pressing ‘Add Code’ or entering a command with (escape) and pressing ‘B’ will add a new code block.


Write code in the cell just as you would in a script.


Pressing Run or CTRL/CMD+Enter runs the code and displays its output.


Reading and writing files

Pressing ‘Browse and upload files’ on the left-hand menu brings up the file system, and pressing the ‘plus’ will allow you to upload a file from your local machine. Below, we have uploaded a simple text file called hello_world.txt.

We can use the following code to open the file, add some text, then save a new file.

You’ll now see the new file in the file system, and it will contain our updates.

Working with the File System

We have shown how to upload, update and create a new file. To download the new file, press the three dots in the file system and hit download.

The plus button used to create new files can also be used to create fresh notebooks, which will have no cells or output. 


Commanding cells

You can quickly reorder cells with the move up and move down buttons, as shown in the image below. 


This will reorder your code. (Note that your code may break if you try and run it in the wrong order!)

The Hide Code button will collapse and hide the code; this is useful for very long code blocks that you aren’t currently working on. It is also useful if the readers of your analysis don't care about the technical details and only want to see the results.

Similarly, the Hide Output button allows you to hide long outputs. 

image10.pngThese buttons can also be used together to hide both code and output.

Publishing reports (Workspace only)

Workspace allows you to publish your notebooks as publications. This is a great way to showcase your excellent work and collaborate with other data scientists.

You can publish your notebook by pressing the ‘Publish’ button on the side menu. From there, hit publish to share your notebook. It is a good idea to run the notebook from top to bottom before publishing. This helps to check your code and ensures it is readable, as most people will read from top to bottom.

Once your notebook has been published, other users can view the publication and comment on individual cells. You can also do the same to others. This is a great way to open up discussion or understand a complex piece of code. Here’s a Workplace example

Sharing Jupyter Notebooks (Workspace only)


Sharing workspaces is another useful Workspace only function. Because the notebook is hosted, you can share a public or private, access-controlled link that the receiver can run themselves. 

This is a fantastic way to collaborate. Data Science is a deep and wide field, meaning no single person is expected to know everything. Data scientists must collaborate to get the best results, whether it’s efficient code, compelling visualizations, or an accurate model. Workspace allows real-time collaboration, where multiple people can edit a notebook at once.

To share your notebook, press the share button on the top right. Here you can copy the link, make the notebook private/public, and set who can access the notebook (if private).

Take it to the next level

Start your data science journey today by signing up for DataCamp Workspace for free. If you get stuck, the Workspace Documentation is a great place for more information.

Learn more about Python

Certification available

Introduction to Python

BeginnerSkill Level
4 hr
Master the basics of data analysis with Python in just four hours. This online course will introduce the Python interface and explore popular packages.
See DetailsRight Arrow
Start Course
See MoreRight Arrow

Google Cloud for Data Scientists: Harnessing Cloud Resources for Data Analysis

How can using Google Cloud make data analysis easier? We explore examples of companies that have already experienced all the benefits.
Oleh Maksymovych's photo

Oleh Maksymovych

9 min

The Top 8 Business Analyst Skills for 2024

Explore the top technical and soft business analyst skills needed to succeed and how you can best showcase them in your portfolio and on your resume.
Joleen Bothma's photo

Joleen Bothma

11 min

A Guide to Docker Certification: Exploring The Docker Certified Associate (DCA) Exam

Unlock your potential in Docker and data science with our comprehensive guide. Explore Docker certifications, learning paths, and practical tips.
Matt Crabtree's photo

Matt Crabtree

8 min

Functional Programming vs Object-Oriented Programming in Data Analysis

Explore two of the most commonly used programming paradigms in data science: object-oriented programming and functional programming.
Amberle McKee's photo

Amberle McKee

15 min

A Comprehensive Introduction to Anomaly Detection

A tutorial on mastering the fundamentals of anomaly detection - the concepts, terminology, and code.
Bex Tuychiev's photo

Bex Tuychiev

14 min

Pandas Profiling (ydata-profiling) in Python: A Guide for Beginners

Learn how to use the ydata-profiling library in Python to generate detailed reports for datasets with many features.
Satyam Tripathi's photo

Satyam Tripathi

9 min

See MoreSee More