Change the code into a function which takes the start time and the end time and returns the tempo.