Jupyter is a web application where you can store Python code, results (visualizations, graphics, things to display, etc.), and formatted text. It can be compared to a web page with Python applications ... just like this course!
There are, of course, other ways to work with Python. But first, we want to introduce you to Jupyter so you can see why we recommend it for your Python projects.
What is Jupyter Notebook?
In this case, "notebook," or "notebook documents," denote documents that contain both code and rich text elements, such as figures, links, and equations. Because of the mix of code and text elements, Jupyter Notebook is the ideal place to gather and analyze the contents. It can perform data analysis in real time.
Therefore, you can delimitate the different parts of your code with some additional text, which allows others to read and understand your code.
It's also convenient for prototyping or trying a part of a code, examining the results, and potentially adding it to your main project. You don't have to worry about building a script with mains, functions, etc. You just have to write your code in the different pre-designed blocks and execute it: there you go, you are running some Python!
Jupyter Notebook in data science
A Jupyter Notebook is a popular tool among data scientists. It allows teams to create and share their documents, code, and even full-blown reports allowing for more productivity and better collaboration.
For example, one of the ways that data scientists and engineers at Netflix interact with their data is through Jupyter Notebooks: the movie recommendation algorithm is written with Jupyter! Check out this article on Medium for more information.
Getting started with Jupyter Notebooks
Now that you have installed Jupyter and understand it a little more, it's time to get started!
First, open Jupyter Notebook: it will open a new page in your browser, called Home. Start by creating a new notebook:
You will immediately see the notebook name, a menu bar, a toolbar, and an empty code cell. Start by writing your first Python line code in this empty cell, and click run. Start by saying hello.
print('Hello World !')
Different cell types
Before diving into programming concepts, you should know the four cell types in a Jupyter Notebook: code, markdown, raw nbconvert, and heading.
Let's review each of them:
Code - the classic cell, like the first empty one you have when you create a notebook. This one is designed to write codes! You can execute your code by clicking the run button.
Heading - this one is deprecated. It was designed for titles, but you can now use markdown. It will probably disappear in the next versions of Jupyter.
Raw nbconvert - only intended for use with the nbconvert command line tool. Basically, it allows you to control the formatting in a very specific way when converting from a notebook to another format.
Markdown - markup language that is a superset of HTML. It is designed to write your comments, titles, notes, etc. Click here to learn more about it.
You will primarily use the code and markdown cell types. For both types, you simply write and run your text.
You can apply some tags to style your text! For instance:
Titles: use the
#. One # will be a title 1, two # will be a title 2, etc.
Lists (bullet points): use the
*notation in front of each item. Try the following text:
* first* second* first sub-second* second sub-second* third
Bold: with the
<b> your text... </b>tag.
And everything allowed with HTML!
You now have your Python environment installed and know how to use a Jupyter Notebook. Let's get our hands on some Python programming in the next part of the course!