Jupyter allows the making of interactive documents that merge text, code, and graphics. It shares widespread use in scientific computing for sharing both code and results. Jupyter notebooks consist of code cells and Markdown; easy to create and rearrange.
Programming might come to mind as simply entering code into an IDE, a text editor, or an interpreter. Jupyter offers a fundamentally different approach, allowing for the seamless integration of text, code, and graphics within interactive documents. It combines ease of use with powerful capabilities.
Jupyter is a "notebook interface" where you can create "literate programs"- code interspersed with description. It was born out of the IPython project, which had been designed to improve the interactive experience for users of Python. Jupyter contains IPython but can also operate as a standalone application. Jupyter does not just support Python, as its name might imply; it offers numerous programming languages through different "kernels." Python is one of the options among the many available.
You probably have heard the notion that good programs should contain comments explaining anything that might confuse someone reading your code — or you, if you return to it after a while. But, the notebook takes this idea a step further. You can create documents that describe what you did, including graphics and code.
Here is an example I made in my spare time using Python and Seaborn to show the trend line of a dataset that records the number of airline passengers from late 1950s to early 1960s. This is just one kind of project you might work on.
Jupyter has gained a lot of popularity in scientific computing, specifically in data analysis and data science because it offers an easy way for the researcher to convey any results. However, its application is not restricted to scientists; Jupyter can be used by anyone for regular coding tasks and effortlessly showcase their work to others. This approach to programming creates interactive documents as opposed to just running code.
One advantage of using Jupyter over a typical interactive interpreter like Python's is that it maintains an automatic log of your activities. In fields like science and engineering, this acts as a way to "prove your work.
Which is better: Jupyter Notebook or JupyterLab?
Jupyter has two types: the regular Jupyter Notebook and JupyterLab. JupyterLab is made to give more tools, like a development environment. Even though the Jupyter project first dropped the old Jupyter and put it in maintenance status, it later chose to bring back the old Jupyter because of its lasting use and now runs both types at the same time.
This will be a primer on the classic Jupyter Notebook interface because it is an easier point of entry than JupyterLab. Even though Jupyter developers consider JupyterLab to be the future of their project, you might prefer to stick with the former for now to see if you like it after learning Jupyter.
Installing Jupyter
Installing Jupyter is very simple.
The simplest way to install Jupyter is through pip:
Execute the command pip install notebook.
Another way is to use Conda or Mamba, they are made for complex environments whose purpose is data science and power users. Also, you can find these tools in package managers for Linux distros because they’re commonly used by data scientists and advanced users to manage more complex environments. So it’s a good idea to check your repositories.
Starting Jupyter
To start Jupyter from the terminal in Linux, type:
If the application fails to launch automatically, try to open your browser and go to localhost:8888. You will see a lot of startup information and then a browser window with the Jupyter interface. You will get a browser-based file manager first.
Starting a New Notebook
To create a new notebook, go to the File menu and click on New, then select Notebook. This will open a new tab with the notebook, initially titled Untitled. To rename it, click on the title and a window will pop up for you to change the name of the notebook. Once you've typed in your preferred name, hit Save to confirm. Because this is a Python notebook, it will have the .ipynb extension. When you open Jupyter, your notebook will be found in the directory of creation.
You will be prompted to select which of the installed kernels you would like to use. For this tutorial, we will select Python, as it is a very popular and easy-to-use language.
Activating and Mobilizing Cells
A notebook consists of cells that can hold text or code. You can choose the type of cell from a drop-down menu labeled "Code" or "Markdown." The cells are set to code by default.
To input text in Markdown mode, use the standard Markdown syntax. In a code cell, employ the language kernel that you have selected.
To run a cell use Shift+Enter. When applied to a Markdown cell this will format the Markdown accordingly; while in a code cell it will execute the code and provide the output. If the execution of the code is successful a value will be returned. Any error messages will be displayed in red.
To change a cell after it has run, just click on it. Then, press Shift+Enter again to run it.
To show these ideas, we will make a simple example that says "Hello, world!" First, a text cell will be added to tell why this program exists. Next, we will add a Markdown cell with a note like "This is a notebook that prints 'Hello, world!'
We shall do that and get a text cell.
To add a code cell, click the button on the right side which features a box above a plus sign; this will allow you to insert a cell below the current one.
You can also use the B key as a shortcut on your keyboard.
Ensure that "Code" is selected in the drop-down menu and then enter this into the box:
print("Greetings, universe!")
In code cells, Jupyter does automatic syntax highlighting, which helps you to ensure that the code is entered correctly.
You should now see "Hello, world!" appear below the code cell by pressing Shift+Enter again. The button located to the left of the "insert cell below" function will do the same action but will add a cell above this one.
The cells can be moved around. On the right side of each cell, several icons are displayed. These icons enable you to move the cell up or down, add a new cell above or below, and duplicate the current cell. Duplicating an operation is useful if you want to do the same operation with different parameters; for example, changing the value of a variable.
Your notebook will be saved at intervals by Jupyter. You can choose "Save Notebook" from the File menu or use the shortcut Ctrl+S.
To leave the notebook, you can select "Shut Down" from the file menu, which will trigger a confirmation window. To completely close the Jupyter server, you can either select "Shut Down" from the file menu or Ctrl+C in the terminal where you started the Notebook.
This helps you get started with a strong new way of programming with Jupyter notebooks.







