Here’s the solution:

# Exercise 1
from IPython.display import Latex, Image, display, HTML
from numpy import *
from matplotlib.pyplot import *
from scipy.stats import linregress
from scipy.optimize import curve_fit


## So what’s going on ?

Here we are importing the libraries that contain all the functions we’ll need for the purpose of these exercises. As always, feel free to google them to find out everything about what they do, but here’s the gist of it:

• IPython.display refers to the basic Jupyter (the framework we’re using to run Python scripts online) library. In particular, we want to load modules to write mathematical expressions nicely in $\LaTeX$ and save plots as images.
• numpy stands for “numerical Python” and contains lots of numerical tools we’re going to need (and the values of constants like pi). The star * after import means “everything”; this is fine for now, but one should be careful about such statements when writing more complicated scripts, with possibly overlapping libraries (object definitions might conflict, and the namespace is being filled unnecessarily).
• matplotlib contains all the tools we need to create plots (another commonly used library is gnuplot).
• linregress and curve_fit are the two statistical functions we need to extract from the scientific library (scipy) to compute linear regressions and $\chi^2$ fits.

Solutions to exercise 2