How
Contents
How#
Install Anaconda#
Navigate to https://www.anaconda.com/products/individual
Download the distribution of anaconda for your Operating System
Run the installer
Start a Jupyter notebook server#
Open a command line tool (
Anaconda prompt
on Windows,terminal
on OS X);Type
jupyter notebook
and pressEnter
Create a new notebook#
Navigate to the location you want using the Jupyter interface;
Click on the
new
button in the top right;Rename the notebook (change
Untitled
in the top left to a name of your choice).
Find/open a notebook#
Using a file browser you can navigate the directories and files on your computer. Jupyter notebooks appear as generic files with the .ipynb
extension.
You cannot double click on these to open them, you need to navigate to them through the Jupyter interface.
Run Python code#
In a Jupyter notebook cell write an instruction, for example:
3 / 5
and click on the Run
button or use Shift + Enter
as a keyboard shortcut.
Carry out basic arithmetic operations#
The python code for the following arithmetic operations are:
Addition, \(2 + 2\):
2 + 2
;Subtraction, \(3 - 1\):
3 - 1
;Multiplication, \(3 \times 5\):
3 * 5
;Division, \(20 / 5\):
20 / 5
;Exponentiation, \(2 ^ 4\):
2 ** 4
;Integer remainder, \(5 \mod 2\):
5 % 2
;Combining operations, \(\frac{2 ^ 3 + 1}{4}\):
(2 ** 3 + 1) / 4
;
Note that instructions to a computer (through the code we write) need to be specific. For example the ^
symbol in Python does not mean exponentiation. If you were to type 2 ^ 4
you would get an error.
In later chapters we will see what the specific instructions are to carry out more complex operations.
Write markdown#
To write markdown click on a cell and change the type to Markdown
, you can do
this by click on Cell
, Cell Type
or by using the scroll wheel in the menu
bar.
Markdown is a lightweight “mark up” language that allows you to write and include various types of formatting which include:
Headings;
Bold and italics;
Ordered and unordered lists;
Code (which will only be displayed but not run);
The syntax is relatively straightforward and the following is a good guide:
Write basic LaTeX#
Jupyter notebooks allow for markdown cells to not only include markdown but also include mathematics using another “mark up” language called \(\LaTeX\).
Here is a brief overview of the syntax for arithmetic operations:
$a+b$
gives: \(a + b\):$a-b$
gives: \(a-b\)$-a$
gives: \(-a\)$ab$
gives \(ab\)$a\cdot b$
gives \(a\cdot b\)$a\times b$
gives \(a\times b\)$a/b$
gives \(a/b\)$\frac{a}{b}$
gives \(\frac{a}{b}\)$a ^ b$
gives \(a ^ b\)
The $<expression>$
delimiters create what is called an “inline” mathematics.
You can change the brackets to $$<expression>$$
to give “displayed
mathematics”.
We can write a matrix:
$$
\begin{pmatrix}
a&b\\
c&d\\
e&f\\
\end{pmatrix}
$$
gives:
We can write integrals:
$$
\int_{0}^{\infty}x dx
$$
gives:
We can write summations:
$$
\sum_{0}^{n}i
$$
gives:
Save the output in a different format#
Click on File
then Download as
and choose the format you want to use. HTML
is a portable option that can be viewed on most devices, note however that you
cannot run the cells: what you are downloading a is static version of your
notebook.