You should have a Python 3 notebook open, if not take a look at the setup page (the previous page in the schedule).
Jupyter provides a nice web-based interface to Python. In the below cells you can type a line of Python. For example, here we type in
a = 5
When we press SHIFT+Return
this Python line is interpreted interactively
a = 5
To see that this has worked, let's print the value of a
print(a)
You can type whatever Python you want, and it will be evaluated interactively. For example...
b = 10
print(a + b)
One of the cool things about a Jupyter Python notebook is that you can edit the above cells and re-execute them. For example, change the value of b
above and re-execute the lines [3] and [4] (by selecting the cell and pressing SHIFT+Return
.
All of the standard Python help is available from within the notebook. This means that you can type
help(something)
to get help about something
. For example, type and execute help(print)
to get help about the print function.
help(print)
You can set the name of the notebook by clicking on the name at the top, and setting the name. The notebook is currently saved to a file called Untitled
(the extension is short for 'interactive python notebook'). You can save the notebook using the File
menu at the top, using Download as
e.g. saving as a normal Python script, or as a PDF file, webpage or downloading the python notebook itself.
More information is available at the Jupyter website.
Another useful feature is that you can mix documentation into your notebook. Do this by selecting a cell and using the dropdown menu (on the toolbar at the top) to change the cell type to markdown. You can now add documentation, using markdown formatting. For example, use the hash symbol for headers.
Typing
# This is a big header
## This is a subheading
### This is a sub-sub-heading
and pressing Shift + Return
results in:
You can add in hyperlinks using square brackets and round brackets. For example
[link to github](https://github.com)
produces: