Imports and functions

Latest Page Update: 23-09-2026

Solution is now available! Download the full solution from here: Solution

Start by importing some useful functions:

import os
import math
import numpy as np
import matplotlib.pyplot as plt

Python Notebook usersΒΆ

If you're using a Python Notebook for the exercises, you'll need to first run one of the following lines:

# Run this line within a Python Notebook code cell on its own
!pip install ipympl
# Or in your terminal run...
conda install -c conda-forge ipympl

Having done so, add the line:

%matplotlib widget

along your imports. Note that you need to restart your kernel or reopen your notebook for this to be applied.