**1.Introduction > 1.Getting Started**

**1.IPython Notebooks**

Author: Andreas Freise

IPython Notebook is an interactive environment, in which you can combine code execution, text, mathematics, and images. It provides a platform that facilitates transparent and reproducible research as input data; code; analytical expression; explaining text and figures; computations; and results such as output data and figures, can be gathered and performed in the same notebook document. Because of this we believe that we and other researchers will use IPython notebook more and more frequently to present scientific results.

For the same reasons IPython Notebook also provides an excellent platform for teaching and learning numerical modelling, which we utilise in this course. In this notebook we go through the notebook basics you need to follow this course.

**Prerequisites**

*Simulation_preparation.pdf*.

**After this session you will be able to...**

- Use the basic features of an IPython notebook
- Plot results

Python is a powerful programming language which is particularly useful for fast development and scripting. We will use only a very small subset of Python's functionality. In particular, we will do simple mathematical operations (using the package Numpy), some simple string operations and we will plot output data.

I recommend that you do **not** try to learn Python or IPython in general right now, but search the web for a solution for each particular task. A good starting point, for example, is the A Crash Course in Python for Scientists.

More info can be found in:

- The Python tutorial
- The Numpy tutorial

`Cell-->Cell Type-->Markdown`

in the toolbar above, or by using the keyboard shortcut `esc+m`

.

In [2]:

```
# Adding numbers
a=5
b=10
print(a+b)
```

In [3]:

```
# Joining strings together
one='red '
two='car'
print(one+two)
```

In [4]:

```
import numpy as np
# Outputting sentences
r = 2
area = np.pi * r*r
print("This is a good way to present results: The area is {0:.1f} km^2".format(area))
```

In [6]:

```
from IPython.display import display, HTML
a=5.512;
h=HTML('<b>This is bold: {0}</b>'.format(a));
display(h)
```

Note that we needed to import the packages `display`

and `HTML`

from `IPython.display`

.

In [10]:

```
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
x=np.linspace(1, 100, 10) # this creates a data vector with 10 elements
print("x = {0}".format(x))
y = x*x
fig = plt.plot(x, y)
plt.title('A simple function')
plt.xlabel('x [some units]')
plt.ylabel('y [some other units]')
plt.show(fig)
```

Note that we imported `matplotlib`

and added the line

`%matplotlib inline`

to make the plots appear in the notebook instead of popping out as new windows.

In this notebook we have seen how to...

- write code
- write text
- write math
- display figures
- plot results

by using IPython noteobok. In the next session you will learn about PyKat, which is a python wrapper for our simulation software FINESSE.