How to Use Jupyter Notebook Online for Python

Jupyter Notebooks are known as a powerful way to write and iterate on the Python code for data analysis. You are able to write lines of code and run them one at a time, rather than writing and rewriting a whole program. Then, if a change is needed, you are able to go back and edit and rerun the program again, all of them are done in the same window.

For your information, Jupyter Notebook is built off of IPython, the name of the intercative way of running Python code in the terminal using the REPL model or Read Eval Print Loop. The computations are run by the IPython Kernel. it also communicates with the Jupyter Notebook front end interface. Aside from that, it also allows the Jupyter Notebook to support some different languages. The IPython is extended by the Jupyter Notebook through the additional features, like storing your code and output and allowing you to keep markdown notes.

How to Use Jupyter Notebook Online for Python

If you prefer to watch a video instead of reading an article, there is a video shared by Codeacademy about the instructions on how to use a Jupyter Notebook. The video delivers the same information: https://www.youtube.com/watch?v=oJ6z02N0Te0&feature=emb_logo.

If you want to launch a Jupyter Notebook. First of all, you will have to open the terminal and navigate to the directory here you will save the notebook. Then, enter the command jupyter notebook and the program will instantiate the local server at localhost:8888 or another specified port. Doing so should make the browser windows pop up with the Jupyter Notebook interface, otherwise, you are able to use the address it gives you. There is a unique token of the notebooks since the software uses pre-built Docker containers to put the notebooks on their own unique path. If you want to stop the server and shutdown the kernel from the terminal, please press Control-C twice.

When you are in the Jupyter Notebook interface, you will be able to see all of the files in the current directory. Each Jupyter Notebook is identifiable by the notebook icon located next to their name. For those who have already a Jupyter Notebook in your current directory that you want to view, you can just find it in your file list and click it to open.

If you want to make a new notebook, you will have to go to New and choose Notebook – Python 2. You are able to click Upload and navigate to the certain file if you have the other Jupyter Notebooks on your system that you want to use.  Apparently, the Notebooks that are currently running will have a green icon, while the ones that are not running will be grey.

When you open a new Jupyter Notebook, you will be able to see that it has a cell. For your information, cells are how notebooks are structured and are the places where you write your code. To be able to run a piece of code, you can just click on the cell to choose it and then hit Shift + Enter at the same time or press the play button in the toolbar above. In addition, there are several options in the Cell dropdown menu that can be used to run cells, including running one cell at a time or to run all cells at once.

After running a cell, the output of the cell’s code will show up in the space below. If you want to stop running a piece of code, please press the stop button. If you want to make new cells, you can just use the plus (+) button located in the toolbar or press Shift and Enter simultaneously on the last cell in the Notebook. If you want to cut, copy, delete or just generally edit cells, you can just choose the cell that you want to modify and go to the Edit button in the navigation bar to see your options. Apart from running lines of code, you are also able to include the text only cells that use Markdown to format and organize your notebooks. When a new cell is created, it will default to being a Code cell. To make a cell that uses markdown, please click on the Cell menu from the navigation bar, scroll down to Cell Type and select Markdown.

Sometimes, you might have to restart the kernel. To do so, go to the Kernel dropdown and press Restart. In order to shut down the kernel, you should click Shutdown, which will have a dialogue process asking if that is what you would like to do. If you want to force an immediate shutdown, you can go to the File dropdown and click Close and Halt and the browser window will close itself. Please be careful as restarting and shutting down the kernels will affect your variables.

In the Help dropdown, you will be able to find the useful information such as keyboard shortcuts and the links to different documentation for modules such as SciPy, Numpy, and Matplotlib. There are some shortcut buttons in the toolbar for the popular sections. Those include save, add a new cell, cut selected cells, copy selected cells, paste cells below, move selected cells up, move selected cells down, run, interrupt the kernel, restart the kernel, a dropdown that allows you to change the cell type, and a shortcut to open the command palette.

The files of the Jupyter Notebook will be saved as you go. They will be placed in the directory as JSON files with the extension .pynb. You are also able to export the Jupyter Notebooks in the other formats like HTML. If you want to do so, you can just go to the File menu, scroll down to Download as and choose the kind of file that you are looking for. This step will make a pop up show up asking where you want the new file to download. After you have navigated to the right directory, you can just click Save and Checkpoint.