Jupyter notebook is an open-source web application which allows it to create and share documents containing live code, visualizations, equations, and narrative text. Their uses will include data cleaning and transformation, statistical modeling, numerical stimulation, machine learning, data visualization, and more in Python for Data Science.
Jupyter supports more than 40 programming languages, and Python is also there. Anaconda can be downloaded from anaconda.org.
Installing Jupyter Notebook:
Command for running Jupyter notebook:
It prints information about notebook server in our terminal. This also includes URL of the web application (default is, http://localhost:8888) and we will open default web browser to this URL.
When notebook opens in browser, the Notebook dashboard can be seen. It will show list of notebooks, files, and subdirectories in the directory where notebook server was started.
Creating a new notebook:
We can see a new button on the top right corner on the dashboard. When we click on it, a drop-down list will open. Then we should click on Python3 which will open a new notebook.
Some useful commands:
- The command for opening a notebook in the currently running notebook server is as follows:
- The notebook server will start on port 8888 by default. In case port 8888 is unavailable the notebook server will search for the next available port. A port can be specific manually as well. In the example below, we set the server’s port to 9999.
- The command for starting the notebook server without opening a web browser is as follows:
- The server of the notebook will provide help messages for command line arguments by using the help flag:
Running code in Jupyter:
- After the installation of Jupyter, we should write ‘jupyter notebook’ in the command prompt. It will open a new notebook server in our web browser.
- Then we should click on the new button and select Python 3 from the dropdown. It will open a new notebook tab, and we can start writing our code.
- We should press Enter or click on the first cell of our notebook in order to enter edit mode.
- Now we can write any code.
- The code can be run by pressing Shift+Enter or run button which is present at the top.
Useful keyboard shortcuts: