What is Jupyter Notebook ?
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.
- Click on this link to download the latest version of the Python.
- Now, double tap on the downloaded file, the following window is opened. Select Install Now to Install Python.
- You can see that installation is in process.
- 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.
- Open the command prompt.
- Copy/ set the path, where the Python script is presented.
- To upgrade the older version of pip, give the following command after the specified path
- To install the Jupyter Notebook, type the below command:
- It takes a few seconds to install the Jupyter Notebook.
- 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.
- 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.
- It is used to show currently running notebooks.
- 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 -
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.
- Includes mathematical equations using Markdown cells.
- 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.
- Now, the new notebook opens in a new tab.
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.
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.
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.
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
- 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
- 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.
Headers in Markdown
Headers in Markdown output
- The ordered list starts with 1. Use tab to make the suborder followed.
Ordered Lists in Jupyter
Ordered Lists in Jupyter Output
- In Jupyter notebook, if text starts with the dash (-) symbol, markdown cell converts dash into a solid circle and asterisk (*) to a solid square.
Bullet Lists in Jupyter
Bullet Lists in Jupyter Output
- 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 ().
Hyperlinks in Jupyter
Hyperlinks in Jupyter Output
- 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.
Table Content Output
- 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.
- 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
- The following image is inserted on the Notebook.
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.
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.
1. Text widget
- The text widget allows the user to write the String.
2. Button widget
- The button widget is similar to the HTML button.
3. Color picker
- The Color picker allows you to select a color as per to your requirement.
- When you click on the square box, the following color box will open.
Color Picker Box
- Slider is used to find the range and interval between two entities
For add two numbers