Hack 0: What is this thing?

This is an IPython notebook. It is a format for writing, sharing and presenting technical documents, such as scientific analysis. Each section in this notebook is caled a 'cell'. The current cell is designated as a markdown cell. This means, that it is meant to show mostly text. The markdown format is used by many to document software and other things, and allows some light annotations, to add things like links, images, section headings, etc.

When you hit shift-return, this cell gets rendered.

The following cell is a code cell. When you hit shift-return in that cell, the code in that cell gets executed


In [1]:
a = 1

That wasn't too sophisticated, but notice that as long as the kernel is running, that variable persists. For example, the following cell does what you might expect.


In [2]:
print(a)


1

We'll get to plotting in a little while, but for now let me just show you that you can embed figures in the notebook, by setting a magic command: %matplotlib inline.


In [3]:
%matplotlib inline

If you run that, the plots that you create will get embedded into the notebook. See the following cell for a simple example (we'll explain all of this example in a later section)


In [4]:
import matplotlib.pyplot as plt
plt.plot([0, 1, 2, 3, 4, 5], [0, 2, 4, 8, 16, 32])


Out[4]:
[<matplotlib.lines.Line2D at 0x105f3d590>]