Starting up with Jupyter

In this notebook, I am hoping to get you started writing code in Python within Jupyter. I'm only discussing very basic useage of Jupyter here. More detailed useage will be described in class.

What is Jupyter?

Jupyter is a notebook interface for programming, and presenting information. This document is actually a Jupyter notebook. Many programming languages work with Jupyter, but we will be using Python 3. You can read more about Jupyter on the jupyter website.

Jupyter allows for text to be written in Markdown and LaTeX. Markdown makes it easy to write web documents with simple syntax. This Markdown cheatsheet makes it easy.

In particular, LaTeX allows the inclussion of formulas, e.g., $$\frac{n(n+1)}{2}=\sum_{k=1}^n k.$$

There are many ways to install and run Jupyter. I'm trying to collect information on how to get Jupyter running on the class website. I think most people will be installing Anaconda, and I am assuming you have already installed Anaconda.

Starting Jupyter

Once you have Anaconda installed, you should be able to run Anaconda Navigator. There is some documentation for Anaconda Navigator on the anaconda website. When you read it, you should be greeted by a window like the one below.

Anaconda Navigator window

Click the Launch button in Jupyter Notebook box. This button is shown in blue in the above screenshot. A web browser (or tab) should open looking something like the following window:

The Jupyter home screen

The Jupyter home page is just a file browser with the ability to launch a Jupyter notebook file. You'll probably want to navigate to a folder devoted to Jupyter notebooks for this class. Then, to create your first jupyter notebook, you click the New dropdown menu then click Python 3. Your New menu should look something like this:

The new menu

Once you do that, another browser tab should open containing a Jupyter notebook with the default name Untitled. You should see a page like the following but without any code yet:

A jupyter notebook

In your window, you should just have an empty box where print('Hello World!') appears above. To make Jupyter say &lquot;Hello World&rquot;, type print('Hello World!') into this box. Then press Shift+Enter. The text Hello World! should appear along with another input box. If you type 35*17 and Shift+Enter, you should get the answer 595 as above.

The third box is a bit trickier. Our code is spread over three lines. Type a = 5 followed by Enter. You should be moved to a new line in the box. Again type b = 3 followed by Enter. You should again get a new line. Then type a + a*b and Shift+Enter. Jupyter should output 20 as above. You are successfully using variables!


  1. You use Enter to create a new line in an input box, and use Shift+Enter to evaluate an input box.
  2. Spaces in the third box are unnecessary. I just included them to make the code look nicer.

Saving your work

You probably want to save your creation. Click the text reading Untitled at the top of the page. A popup should appear allowing you to choose a new name for your notebook. It should look like this:

the rename dialog

Enter something like My first notebook and click rename. The change should be reflected in the notebook's title as below.

Then you can click the floppy disk icon (depicted with a red dot below). Ths is the save button. Your work will be saved in a file with the name My first notebook.ipynb. The .ipynb is the file extension for a Jupyter notebook.

the save button

You can then exit the notebook by selecting Close and Halt from the File menu. To reopen the notebook, you would go to the file browser tab in Juypyter, find the file you just saved and click on it. Your notebook should reopen.

Remark If you wanted to share your code with someone else, you can share the .ipynb file. You would also upload this file to turn in a homework assignment, for instance.