Module 4 of 13 · Jupyter Notebooks · Beginner

Creating and Saving Notebooks

Duration: 5 min

This module will guide you through the process of creating and saving Jupyter Notebooks using Python. Understanding how to create and save notebooks is fundamental for effective data analysis and documentation. By mastering these skills, you'll be able to efficiently organize your code, results, and explanations in a single, shareable document.

Creating a New Jupyter Notebook

To create a new Jupyter Notebook, you can either use the Jupyter Notebook interface or the command line. Using the command line allows for more automation and integration with version control systems. To create a new notebook via the command line, navigate to your desired directory and run the command jupyter notebook new_notebook.ipynb. This will create a new notebook file that you can open in your browser.

import os

# Specify the name of the new notebook
notebook_name = 'new_notebook.ipynb'

# Create the notebook file
os.system(f'jupyter notebook {notebook_name}')
print(f'Notebook {notebook_name} created successfully.')

Try it in Google Colab: Open in Colab

Notebook new_notebook.ipynb created successfully.

Saving a Jupyter Notebook

Jupyter Notebooks are auto-saved at regular intervals, but it's good practice to manually save your work frequently. You can save the notebook by clicking the 'Save and Checkpoint' icon in the toolbar or by pressing Ctrl+S (or Cmd+S on Mac). Additionally, you can use the keyboard shortcut Ctrl+S (or Cmd+S on Mac) to save the notebook without creating a new checkpoint.

from IPython.display import display, HTML

# Display a message indicating the notebook has been saved
display(HTML('<script>Jupyter.notebook.save_checkpoint(); alert("Notebook saved successfully.");</script>'))
<Alert>Notebook saved successfully.</Alert>

💡 Tip: Remember to save your notebook frequently to avoid losing any work due to unexpected interruptions.

❓ How do you create a new Jupyter Notebook using the command line?

❓ Which keyboard shortcut is used to save a Jupyter Notebook?

← Previous Continue interactively → Next →

Related Courses