Jupyter Notebook: A Getting Started Guide

Filed Under: Python
Jupyter Notebook

Hello, readers! In this article, we will introducing Python coding with Jupyter Notebook. So, let us begin with it.


1. What is a Jupyter Notebook?

Let us first understand the concept of the Jupyter Notebook in the tech world. Prior to that, do you guys know what is a notebook in technological terms?

So, a notebook is a development environment that enhances the working of REPL and its experience in coding. REPL is an acronym for read-eval-print-loop. It is a programming environment that performs the following functions–

  1. The code gets read line by line
  2. Evaluates, compiles and runs every block of the code independently.
  3. Prints the error immediately after the block of code.

Jupyter Notebook works upon the above functions and features of REPL or notebook.

To be precise, a Jupyter notebook is an open-source web application that lets us create documents that contain live codes, documental understanding, visualizations, etc.

It executes the code/task per block of the notebook independently and displays the result. By this, different sections of the notebook can be utilized for different purposes such as codes, equations, documentation, graphs, etc.

Having understood about Jupyter notebook, let us now have a look at its plus or merit points.


2. Advantages of Jupyter Notebook

  • Code can be written and shared in a live environment i.e. dynamic execution
  • Blocks to write documentation of the work
  • Dynamic execution of the code blocks at runtime.
  • When we open a notebook, it not only displays the code but also the output from the code (if you had previously run the code)
  • Data science and machine learning projects can be considered as the biggest application of Jupyter notebooks to handle and maintain large pieces of code.

3. How to Install the Jupyter Notebook?

In order to install, you need to have python environment running on your system.

We would be using Python Manager (PIP) to install the Jupyter notebook on our systems. For the same, make sure you have the latest and upgraded version of pip running using the below command-

python -m pip install --upgrade pip

Further, open the command prompt, and type the below command to install jupyter notebook–

python -m pip install notebook

After the installation, the path of Jupyter notebook gets added to the list of environment variables which in turn helps us run it from the terminal itself.

Last but not the least, let us now open the Jupyter notebook-

To run the notebook, we need to execute the below command in the command prompt,

jupyter notebook

This opens the UI of notebook on the system’s default browser. To add, the moment you close the terminal, it ends the jupyter notebook session.


4. Jupyter Notebook with Python

In the context of this topic, we will now have a look at the below mentioned features of notebook–

  1. Creation of folders
  2. Creation of iPython notebook
  3. Button icon features to use
  4. Writing Python code in Jupyter notebook
  5. Markdown in Jupyter notebook

So, let us begin! 馃檪


1. Creation of folders & iPython notebook

On the upper right corner of the notebook, we would find the Files tab. Click on the New button. From the drop-down, select Folder. This would create an untitled notebook in the directory.

I we want to create a new notebook to work on Python, click on the Python 3 from the drop-down under the New button. This would create an Untitled notebook and would appear in a new tab.


2. Button Icon features in Jupyter Notebook

Have a look at the below snapshot-

Options In Jupyter Notebook
Options In Jupyter Notebook
  • We can create a new block using + sign.
  • Further, we can shuffle the blocks using up arrow & down arrow keys.
  • In order to delete a block, the scissor icon can be used.
  • The Run button can be used to run the code within a block. Alternatively, Shift + Enter can also be used to run the code.
  • The Refresh icon can be used to refresh the notebook. All the variables used within the notebook would be reset.

3. Writing Python code in Jupyter Notebook

We can write and execute python code within blocks as shown below–

Writing Python Code In Jupyter Notebook
Writing Python Code In Jupyter Notebook

The value set to the variables can be used across different blocks and is independent of the scope of the block.


4. Markdown

In order to add meaning to the existing codes or equations, we can make use of Markdown in the notebook. You can select Markdown from the drop-down whose default value is Code.

In the markdown, we can add headings to our plain text. For the same, we need to type # and a space to start the heading quote.

Single # is for Heading 1

## for heading 2 and so on..

Example:

Markdown In Jupyter Notebook
Markdown In Jupyter Notebook

Output:

Markdown Output
Markdown In Jupyter Notebook Output

Conclusion

By this, we have come to the end of this topic. Feel free to comment below, in case you come across any question.

For more such posts related to Python programming, Stay tuned with us.

Till then, Happy Learning!! 馃檪

Further read – Jupyter notebook documentation

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content