/  Technology   /  How to Code in Python using Jupyter
HOW TO CODE IN PYTHON USING JUPYTER 6 (i2tutorials)

How to Code in Python using Jupyter

The Jupyter Notebook is an open-source web application that you can use to create and share documents that contain live code, equations, visualization, and text.

The Jupyter was originally developed as a part of the Ipython project, which was used to provide interactive online access to python. Gradually it becomes useful to interact with other data analytic tools such as R.

The name Jupyter is derived from the combination of ‘Julia’, ‘Python’, ‘R’. As Jupyter runs good in many programming languages but python is a requirement for installing Jupyter Notebook.


Installation

There are a few ways through which you can download Jupiter. You can directly download jupyter from its official site.


How to Code in Python using Jupyter 1 (i2tutorials)


However, in jupyter’s official website, it is recommended to install jupyter notebook using anaconda distribution which includes python, Jupiter, and other packages for scientific computing.


This also allows you to launch applications and manage Anaconda packages, environments. All we need to do is install Anaconda. You can download it.

How to Code in Python using Jupyter 2 (i2tutorials)


After installing anaconda you can start jupyter notebook by using the following command in Anaconda prompt.

 >>>jupyter notebook


This will startup Jupyter and your default browser should start to follow. After you launch jupyter notebook the first page that will encounter is the notebook dashboard.


How to Code in Python using Jupyter 3 (i2tutorials)


The dashboard of jupyter notebook will contain the following tabs :


Files Tab:

The files tab displays files and folders under the current directory. It also displays the upload button using which a file can be uploaded to notebook server.


Running Tab:

The running tab shows which of the notebook are currently running.


Cluster Tab:

The cluster tab is provided by the Ipython parallel. Ipython’s parallel computing framework an extended version of Ipython kernel.


Creating Notebook:

To create a new notebook, click on the New button in the upper right and select a kernel from the dropdown. The kernels listed depend on what’s installed on the server. Some of the kernels in the picture below may not exist as an option.


How to Code in Python using Jupyter 4 (i2tutorials)

For simplicity let’s choose python 3.


Now your webpage should look like this.


How to Code in Python using Jupyter 5 (i2tutorials)


Naming:

You will notice that at the top of the page is the word untitled. This is the title for the page and the name of your notebook. You can change it by clicking on the word untitled and rename it.


Below it there is menubar. Each menu contains many options:


File Menu:

  1. New notebook: Choose the kernel to start a new notebook.
  2. Open: Takes the user to the dashboard to choose the notebook to open
  3. Save as: save current notebook and start a new kernel
  4. Rename: Renames notebook
  5. Save: Saves  notebook
  6. Revert: Reverts state of notebooks to an earlier checkpoint
  7. Download: Export notebook in various file formats.


Edit Menu:

Edit menu consist of buttons cut, copy and paste cells, delete selected cells, split and merge cells, move cells up & down, find & replace within a notebook.


View Menu:

Buttons in this menu help to hide/display the header, toolbar, and cell numbers.


Insert Menu:

This menu gives you options for inserting cells before or after the current cell.


Cell Menu:

The options in this menu let users run all or specific cells in the notebook. You can also set the cell type to code, markdown, or raw nbconvert.


Kernal Menu:

From this menu you can start, interrupt, restart, or shutdown the kernel. You can also start a new kernel.


Widgets Menu:

From this menu you can save, clear, download, or embed widget state.


Help menu:

Various predefined keyboard shortcuts are displayed from this menu. You can also edit the shortcuts as per your convenience.


Cells:

Cells in the jupyter notebook are of three types.


Code Cells:

Contents in this cell are treated as a statement in the programming language of the current kernel.


Markdown Cells:

This cell contains text formatted using markdown language. All kinds of formatting features are available like making text bold & italic, displaying order, or unordered list.


Raw Cells:

Contents in these cells are not evaluated by notebook kernel.


Running Cells:

If you started with python 3 as your kernel, that means you can write python code in your code cells.



print(‘Hello World’) 


For running cells you can click on the Run button or just press Shift + Enter.


When you will run the cell output will be displayed under the code.

Leave a comment