Have you ever wondered why Python has become the most preferred language in multiple industries and educational institutions? It is because Python is simple and more straightforward to use than other object-oriented programming languages. Python also comes with a lot of in-built libraries that make data analysis and machine learning easy to implement.
This blog will help you understand Python with Jupyter Notebook and will help you learn the various features it provides to make programming simple and easy to learn.
To read the official Jupyter Notebook document, visit the website.
Click on Install to learn the steps for installing the Jupyter Notebook.
You will then be prompted to install Jupyter Notebook using Anaconda.
To download the Anaconda Distribution of Python, visit the website and click on the Download tab.
Next, download the latest version of Python for Windows Installer and choose either 64-Bit/32-Bit Graphic Installer based on your system’s configuration.
After the download is complete, install Anaconda to an appropriate location.
Once the installation is complete, you can search for Anaconda in the Start menu of Windows and go to the Anaconda Prompt.
In the Anaconda Prompt, type “jupyter notebook.” This will open the Jupyter homepage in a web browser.
You can also search for Anaconda Navigator and check the things it has got to offer.
As you can see, Ananconda provides a lot of other software, such as Sypder, Orange, RStudio, Visual Studio Code, etc.
To start the Jupyter Notebook, click on Launch, which will take you to the Jupyter homepage. You will be able to see all the files and folders present in the current working directory. You can change the working directory of the Jupyter Notebook any time you want.
Any program written in Jupyter is saved as a .ipynb file, which stands for “interactive Python notebook.” Click on New and select Python3.
It will open a new Jupyter Notebook in a new tab.
Click on the first cell, and type print(“Hello World”). To run the cell, use Shift+Enter.
You can rename the Jupyter Notebook by clicking on Untitled. As shown in the example below, it is named JupyterNotebookBasics”.
To save the Jupyter Notebook file, click on the save icon. Now, you can close the file and open it any time you want from the Jupyter Notebook homepage.
Jupyter Notebooks have kernels, which are programs that run and introspect the user’s code.
Using a kernel, you can interrupt a program while it is running. You can restart a kernel, clear the output of the cells, run all the cells simultaneously, shut down a notebook, or change the kernel if required.
In the below example, you will see that if a kernel is restarted, the previous variables won’t be stored anymore.
Now, if you restart the kernel and run hello, you’ll receive an error message.
To run a particular cell, you can either select the Run button or hit Shift+Enter. This will create a new cell and move the pointer to the new cell once the execution of the current cell is complete.
To clear all the outputs, you can select Restart & Clear Output from the kernel.
You can also run all the cells at a time by selecting Restart & Run All from the kernel.
Similar actions can be performed using the Cell option.
In Jupyter, the output of the code is generated right below the cell that you are running. This makes your code more readable and informative.
The asterisk symbol at the beginning of the cell indicates that the cell is still running.
Once you enter a name, the cell will complete its execution and generate the output.
Jupyter allows you to give titles to any project you are working with. This is possible using the Markdown cell type. Click on Cell and select the Cell Type as Markdown. To give a more prominent size title, use a hashtag (#), followed by a space followed by the name of the title.
Jupyter Notebooks are useful for visualizing any amount of data. It creates the plot using the matplotlib visualization library right below the code. The following is an example of plotting a linear graph:
A Jupyter Notebook can be downloaded in multiple formats. Select File and click on Download as. This will show you the various formats in which you can save a Jupyter Notebook.
This is what the .html format of Jupyter Notebook looks like:
It will open in a web browser, and each line of code can be easily copied on to a Jupyter Notebook.
Learn data operations in Python, strings, conditional statements, error handling, and the commonly used Python web framework Django with the Python Training course.
To get more hands-on experience working with Jupyter, google jupyter notebook repository on git. This provides a lot of resources for practicing code with Jupyter.
We hope that having read this blog, you've understood the Anaconda Distribution of Python, the interface of the Jupyter Notebook, and how to write a Python program in Jupyter, run the cells, rename a notebook, and add a title to the code. You would have also gained knowledge of plotting a simple linear graph using the matplotlib library. Finally, you would have understood how to download a notebook in various formats, such as .ipynb, .py, .html, .pdf, etc.
To get more in-depth training, sign up for Simplilearn’s Python Training course today!