Python and Jupyter

See Code and notebooks for links to the notebooks developed for this class.

Some general resources

Many other tutorials and books can be found online!

Scientific Python

Numpy, Scipy, and matplotlib are the core packages for scientific Python.

Many other packages are also useful, e.g.

Python2 vs. Python3

The notebooks for this class should be compatible with either Python 2.7 or 3.x. The main difference that affects us is that in Python 3 print is a function rather than a statement, e.g.

print('x has the value %.6e' % x)

rather than:

print 'x has the value %.6e' % x

To get a code written using the print function to work in Python 2, you can include this line at the top of the file:

from __future__ import print_function

(with 2 underscores before and after future).

Installation options

The Anaconda Python Distribution is one easy way to get everything you need. If you install this, you can also then use the conda package installer to install various extensions easily.

You might also want to check out conda environments as a way to compartmentalize versions of Python packages for different projects.

Jupyter notebook installation

If you installed the Anaconda Python, you can insure you have jupyter and are up to date via the bash commands:

conda install jupyter
conda update jupyter

Then in a bash shell you should be able to execute:

jupyter notebook

to start the notebook server. You can then navigate your browser to the address shown when the notebook starts, e.g.

http://localhost:8888/tree

If you want to easily run notebooks without installing any software, you might try CoCalc (previously known as SageMathCloud) or binder.

See Code and notebooks for more information about these services and about running the notebooks for this class.