In this blog, I am going to cover some basics of Jupyter notebook, its usage, and its power.
How to Start the Jupyter notebook?
I hope you are using Anaconda Prompt. If not, It is highly recommended to use Anaconda Distribution for the Data Science project.
Download Anaconda: Click Here
- Open anaconda prompt
- set the drive
- write the command
- hit Enter
It will open a Jupyter notebook server in your default browser at
Note: I was already using the default port
localhost:8888 that is the reason It is trying to connect with another port.
A Jupyter notebook is an awesome tool in which you can:
- Write code
- Write some text
- Add images/videos/tables
- You can do almost everything that you do in HTML
means we can write the code and description also in the same notebook.
Let’s dive into it and create an iNTERACTIVE pyTHON nOTEbOOK(.ipynb) file.
How to create a notebook in Jupyter notebook?
- first, click to
- second, In popped option, click
It will create a new
- click on
Untitled(underlined in the above image) to rename the notebook.
- Click the
Renamebutton to finalize the newly entered name.
Understanding notebook(.ipynb) file in more detail
The Notebook consists of cells that you can add or/and delete according to your need.
Each cell can be executed in two different ways(generally):
- Markdown cell
- Code cell
Markdown is a text-to-HTML conversion tool and simply the superset of HTML. In Markdown cell you can write your text either in HTML format or standard Markdown format.
In which we write our code to be executed.
Let’s see the example below…
To execute any cell Hit
In the above image, M is markdown cell and not executed till now.
Just go and click on the markdown cell and execute it…
Wow! You got this result…(below)
- Whenever you execute any cell, a new cell created automatically below to the executed cell. (as you can see in the above picture).
Wow, I hope you are convinced of the power of the Jupyter notebook.
Dive Deeper into the notebook
Let’s Dive Deeper into Markdown cell and How to use it?
First thing first, I hope you are familiar with HTML. If not, don’t worry we’ll not be using HTML to write our text, instead, we’ll use markdown style.
There are six types of headers that you can write using
# in the markdown cell
# and leave a space and write whatever you want as a header.
See the example below in the image.
Shift+Enter. you will get this result
to initialize Unordered list you can use either
— with trailing space.
See the below example…
You can see in the above cell that nested elements are automatically colored differently.
You can see that Jupyter notebook cares about all the nested list numbering.
Some more functionalities of the Jupyter notebook:
- For Bold text, use the text enclosed with two asterisks(**), no space should be there.
- For Italic/emphasized text, use only one asterisk(*), no space should be there.
For Block_quote/comment use
>and the text further.
- I used
<hr>tag for a horizontal breaking.
- Instead of
<pre></pre>of HTML you can type a tab and trail/successor text.
The Output of above markdown command:
Insert Image in the Jupyter notebook:
- Method 1: Copy any image from any source and paste the image to the markdown cell.
- Method 2: Copy the link of the image from the internet source and use
<img src="">tag to showcase the image. Let’s see how?
How to play YouTube videos in the Jupyter notebook.
- Right-click on YouTube video→Copy embedded-code.
- In the code cell write
from IPython.display import HTML.
HTML(Embedded_code), pass Embedded_code as a string.
- run the code cell.
Let’s see how?
Well, suppose using all the above information you have written some notebook, right.
Now, you want to create a new notebook and want to copy the cells from the previous notebook and paste it into a newly created notebook.
Let’s see how?
How to copy and paste more than one cell into the Jupyter notebook among different notebooks?
Steps to copy more than one cell:
- Click on the cell you want to copy from and press
Escto make the notebook in command mode. When you will press
Esc, below red-highlighted pencil will disappear. The sign of a pencil means the notebook is in Edit mode.
- paste it wherever you want(It is also possible for different notebook also).
There are tons of things to explore in Jupyter notebook.
Just play with all the options.
Play with the options, you will get more…
The keyboard shortcut is very helpful to save your lot of time.
Any Query? Comment below…