Jupyter combines interwoven text, data, and code, in a format that runs in a web browser.
Any time you open a notebook, you will be working on your own temporary copy that you can edit without affecting the original or anyone else's work. So please feel free to press buttons and edit and delete things without fear. You can always close and re-open this document if you need to start over.
There are two main parts to a notebook:
Jupyter Notebooks are collections of cells that do different things.
You can navigate through the cells of a notebook (including this one) by using the 'run' command in the toolbar above.
What do the cells do? For this exercise, we'll talk about 2 kinds of cells.
This cell is an example of a markdown cell. Markdown cells just contain text, and are used for commenting code, creating headings, etc.
There are also executable code cells. You can recognize code cells by the pair of brackets and a colon in the left margin, like so [ ]:
Let's try running a code cell to see what happens.
To run the code cell below, click on the cell and then press the "Run cell" button
1 + 1
When you have run the cell, you should see an output appear just below the code cell:
The output after you run a cell essentially forms part of the document as you work through it.
You may have noticed the brackets on the left change from being empty to containing a number. This tells you that the cell has successfully been run. Brackets will give you information about a code cell, like so:
[ ]:
never been run[*]:
still running[1]:
was run 1st of all the cells in the document[7]:
was run 7th of all the cells in the documentIf you run this code cell a second time, you will see the brackets change to [2]:
. The number will always update to reflect the last time you ran the cell. In general, it's a good practice to run cells in sequential order as you work through a notebook to avoid errors.
Running code cells is something you will do a lot of during this workshop! You can either press the run button each time, or you can use the following keyboard shortcuts:
To practice editing a cell, double-click on the cell below. You'll see the cell highlight on the left change from blue to green, indicating that you're now editing a cell.
Try changing one of the numbers or the operator. Then run the cell using the 'run' button or one of the keyboard shortcuts above.
1 + 1
To completely restart this notebook and clear all of your work, click on the "Kernel" menu and then click on the "Restart & Clear Output" option.
Then, click "Restart and Clear All Outputs" on the pop-up window that appears.
This will completely reset the notebook.
Next, we'll look at Getting started with Python.
If you would like to learn more about Markdown, check out this quick Markdown guide or this longer Markdown tutorial.
If you're curious about how we have set this notebook up, read on:
Binder is the environment we are using to access ("run") our Jupyter Notebooks inside a browser. It's kind of like a separate computer in the cloud that makes all of tools we need to use in Jupyter Notebooks work. We're using Constellate's Binder for this session, but anyone can create their own Binder.
We use Github to store the Jupyter Notebooks (.ipynb files) for this session. Like any other computer, Binder will power down after a while--basically after a certain period of inactivity. So we need a place to make our Jupyter Notebooks available, and tell Binder where to find them the next time we start up a Binder session to interact with our notebooks.
Adapted by Kate Kryder and Jen Ferguson from two notebooks created by Nathan Kelber and Ted Lawless for JSTOR Labs under Creative Commons CC BY License.
See here for the original versions. Some content was also adapted from notebooks created by Sarah Connell and Jen Ferguson for earlier versions of this workshop.
___