How to use Jupyter Notebook
Know that Jupyter is not the only option that you can use to run Python, you could also use an IDE like Spyder, or using IPython with a simple Text Editor.
Why Use Jupyter Notebook?
A Python Notebook, like Jupyter Notebook, is the perfect trial and error tool. Jupyter Notebook is an open-source environment that lets you write, read and share your Python code for data analysis.
How To Install Jupyter Notebook?
If you have never installed Python, you should probably install Python using Anaconda.
Anaconda is the perfect Data Science Distribution of Python.
By installing Jupyter Notebook using Anaconda, you’ll also install:
- Useful Data Science libraries: Matplotlib, SciPy, Pandas, Numpy
- Spyder IDE
- Jupyter Notebook
Launch Jupyter Notebook
Now that you have installed Jupyter Notebook using Anaconda, all you need to do to launch Jupyter on Windows is to get the program through your windows navigator.
How To Use Jupyter Notebook
We have installed and launched Jupyter Notebook.
Now, how to use it?
I will show you a step-by-step tutorial to help you use this amazing tool to start coding with Python.
Create a Notebook
The first step is to create a Notebook.
Click New > Python 3
Next step is to give a name to your Notebook.
Use The Jupyter Console
To start using the console is really simple. All you have to do is type in any Python command in the console.
This is the equivalent of using the IPython Console in Spyder.
With this tool, you are going to prompt any command line-by-line.
Let’s build a “Hello World” function.
To run the code, just press
Shift+Enter on your keyboard.
If you understand nothing of the code above, just refer to my guide on Python cited at the beginning of this post.
Create a Python Script in The Notebook
What we just did is only going to be accessibile via the notebook we created.
To build a variable that you can get from many notebooks, we will need to build a Script in a seperate file.
To do this, we are going to create a script instead of a Notebook, like we did in the previous section.
- Navigate to the home page clicking the Jupyter logo on top left.
- Click “New”
- Click “Text Files”
- Click to change the name
- Change to extension .txt to .py
- Click “OK”
- Write your first Function
Import a Function From Your Predefined Script
Here, we have defined a function called
my_function() in a script called
To use it, let’s go back to our “Jupyter Tutorial” Notebook.
- Import the function from the script using
- Call the function by its name.
Use Markdown to Write Text in Jupyter Notebook
This is actually a pretty cool function tha I don’t use enough. You can use Markdown in Jupyter Notebook to write some text in between your code.
This is the perfect storytelling tool to help make your code memorable for later use.
Using Markdown is quite simple.
Go to Cell > Cell Type > Markdown
Write Text in Markdown
To write text in Markdown, just use this quick cheatsheet.
# This is a H1 ## This is a H2 ### This is a H3 ###### This is a H6 *italic* **bold** > Quote * Unordered List * Unordered List * Unordered subList * Unordered subList 1. Ordered List 2. Ordered List 3. Ordered List ![Image](https://www.jcchouinard.com/wp-content/uploads/2019/07/how-to-rank-your-linkedinpage.jpg) [jcchouinard.com](https://www.jcchouinard.com)
For more ideas, just read this post on Github.
At last, you can now start using Jupyter Notebook to run your Python Scripts. Let’s find out how to use Python for DataScience and Python for SEO.
SEO Strategist at Tripadvisor, ex- Seek (Melbourne, Australia). Specialized in technical SEO. Writer in Python, Information Retrieval, SEO and machine learning. Guest author at SearchEngineJournal, SearchEngineLand and OnCrawl.