Jupyter Notebook
What is Jupyter Notebook ?
Jupyter
Read Also
Advantages of Jupyter Notebook
- All in one place
- Easy to convert
- Easy to share
- Language independent
- Interactive code
Disadvantages of Jupyter Notebook
- It is very hard to test long asynchronous tasks.
- Less Security
- It runs cell out of order
- In Jupyter notebook, there is no IDE integration, no linting, and no code-style correction.
Installation of Jupyter Notebook
- To install the Jupyter Notebook, to begin with, you would like to install the Python. You'll take after the below steps to download the Python.
Step 1
- Click on this link to download the latest version of the Python.
Step 2:
- Now, double tap on the downloaded file, the following window is opened. Select Install Now to Install Python.
Step 3:
- You can see that installation is in process.
Step 4:
- Once the installation is completed, the following window is open, you simply click on the close.
- Once the Python installation is completed, follow the below steps to install the Jupyter Notebook with pip package.
Step 1:
- Open the command prompt.
Step 2:
- Copy/ set the path, where the Python script is presented.
For Example:
Step 3:
- To upgrade the older version of pip, give the following command after the specified path
Step 4:
- To install the Jupyter Notebook, type the below command:
- It takes a few seconds to install the Jupyter Notebook.
Step 5:
- Once the installation process is completed.To run your notebook on the server using the following command in command prompt.
Jupyter notebook starts with the default web browser.
Dashboard of Jupyter Notebook
- The following screenshot appears dashboard of the Jupyter Notebook which contains the three tabs.
Jupyter Dashboard
Files Tab
- It is used to display files and folders in the current directory.
- It also uses an Upload button through which a file can be uploaded to a notebook server.
Files Tab
Running Tab
- It is used to show currently running notebooks.
Running Tab
Read Also
Cluster Tab
- IPython provides the Cluster Tab. IPython is a parallel computing framework, which is an extended version of the IPython kernel.
Jupyter Cluster Tab
- To make a new notebook, the notebook will be presented with the notebook title, menu bar, toolbar, and an empty code cell.
Jupyter User Interface
- Notebook name: It is displayed at the top of the page, next to the Jupyter logo.
- Menu bar: To presents different options that are used to manipulate the notebook functions.
- Toolbar: It provides a quick way for performing the most-used operations within the notebook.
- Code cell: It allows you to edit and write a new code.
Components of Jupyter Notebook
- There are the following three components of Jupyter Notebook -
Components
Notebook Web Application
- It is an interactive web application for writing and running the code.
- The notebook web application allows users to:
- Edit code in the browser .
- Run code on the browser.
- See results of computations with media representations, such as HTML, LaTex, png, pdf, etc.
- Create and use JavaScript widgets.
- Includes mathematical equations using Markdown cells.
Read Also
Kernels
Notebook Documents
- Notebook document contains a representation of all content which is visible in the notebook web application, including inputs and outputs of the computations, text, mathematical equations, graphs, and images.
Creating a Notebook
- To create a Notebook in Jupyter, go to New and select Python3.
Creating Notebook
- Now, the new notebook opens in a new tab.
Notebook Open
Read Also
Rename the Notebook
- To rename the Notebook,
- Double tap on the Untitled at the top of the screen.
- A pop up window will open to renaming the file.
- Enter a new notebook title that you simply need to include.
- Then press on the Rename.
Rename the Notebook
How to write and run a program in Jupyter
- Now, you can run it by pressing the Shift+ Enter key or directly click on the run button at the top of the screen.
Run Program in Jupyter
Types of Cells in Jupyter Notebook
- There are the following four types of cells used in the Jupyter Notebook.
Types-1
1. Code Cell
- The contents present in a code cell are treated as statements in a programming language of the current kernel.
- By default, Jupyter notebook's kernel is in Python so you can write Python statements in a code cell.
- When you run the statement, its output is displayed.
- Output can be presented in the form of text, image, matplotlib plots, or HTML tables.
Code Cell
2. Markdown Cell
- Markdown cell provides documentation to the notebook and makes the notebook more attractive.
- This cell contains all types of formatting features such as making text bold and italic, headers, displaying ordered or unordered list, Bullet lists, Hyperlinks, tabular contents, images, etc.
- To perform the following formatting features, first select Markdown cell from the drop-down menu.
Markdown Cell
Bold and Italics
- To make text bold, write text between the double underscores or double asterisks.
Text bold in Jupyter
- The output of the above code
Output
- To make text italics, write text between single underscore or single asterisk.
Italics in Jupyter
- The output of the above code
Italics in Jupyter Output
Headers
- Creating headers in Markdown is similar to the creating headers in HTML. It displays text in 6 sizes.
- To make the text as a header, start the text using # symbol. The number of # symbols depends upon the size of the header.
Sample Code
Headers in Markdown
Output
Headers in Markdown output
Ordered Lists
- The ordered list starts with 1. Use tab to make the suborder followed.
Sample Code
Ordered Lists in Jupyter
Output
Ordered Lists in Jupyter Output
Bullet lists
- In Jupyter notebook, if text starts with the dash (-) symbol, markdown cell converts dash into a solid circle and asterisk (*) to a solid square.
Sample Code
Bullet Lists in Jupyter
Output
Bullet Lists in Jupyter Output
Hyperlinks
- Markdown cell allows you to attach the Hyperlink. To attach the hyperlink place the name of the link in square brackets [] and write link inside the parentheses ().
Sample Code
Hyperlinks in Jupyter
Output
Hyperlinks in Jupyter Output
Table Content
- Markdown cell allows you to create a table using pipe symbol (|) and dash symbol (-). Pipe symbol (|) used for making columns, and dash symbol (-) is used for making the rows.
Sample Code
Table Content
Output
Table Content Output
Images
- To insert the image in a markdown cell, you first need to insert the image in the same directory. Go to Jupyter dashboard -> select Upload, specify the path of an image then click on Open.
Sample Code
- Once the image is seen in the dashboard click on the Upload, you can see that image is uploaded in the dashboard.
- Now, go to your current Notebook, and type the following code to insert the image
Current Notebook
- The following image is inserted on the Notebook.
Inserted Image
Read Also
3. Raw NBConvert Cell
- Raw NBConvert Cell provides a place where you can write output directly. These cells are not evaluated by the notebook kernel.
Raw NBConvert Cell
4. Heading Cell
- The Jupyter Notebook does not support the heading cell. When you select the Heading from the drop-down menu, a pop will open on the window as given below.
Heading Cell
IPyWidgets in the Jupyter Notebook
- The ipywidgets provides many common user interfaces for exploring code and data interactively.
- IPywidgets are installed in Anaconda or you can also install it manually with conda.
Ipywidget
1. Text widget
- The text widget allows the user to write the String.
Sample Code
Output
Text Widget
2. Button widget
- The button widget is similar to the HTML button.
Sample Code
Output
Button Widget
3. Color picker
- The Color picker allows you to select a color as per to your requirement.
Sample Code
Output
Color Picker
- When you click on the square box, the following color box will open.
Color Picker Box
4. Slider
- Slider is used to find the range and interval between two entities
Sample Code
Output
Slider
Read Also
Sample Code
For add two numbers
Output:
Slider Output