top of page

Average Speed and Pace Calculator

The analysis performed in this project helps predict a marathon time based on previous data, but that can't help me calculate my daily speed and pace. This interactive Jupyter notebook helps me determine what my average speed and pace is after each daily run. All I have to do is enter the mileage, hours, minutes, and seconds, and it outputs results. 

Average Speed Calculation

sec_to_hr = 1/3600 # 3600 seconds in 1 hour
min_to_hr = 1/60 # 60 minutes in 1 hour

Input

miles = int(input("How many miles did you run today? "))

​

time_in_hr = int(input("Input the amount of hours it took for your run? "))


time_in_m = int(input("How many additional minutes did it take to run? "))


time_in_s = int(input("How many additional seconds did it take to run? "))

Calculating with inputs 

time_hrs = time_in_hr + (time_in_m*min_to_hr) + (time_in_s*sec_to_hr) # Total time in hours


av_speed = miles/time_hrs # Total time in miles
response = "Average speed = {} miles per
hour".format(round(av_speed,2))


print(response)

Average Pace Calculation with inputs

pace_dist = 1 #1mile


pace_time_hr = round(pace_dist/av_speed, 2)


pace_time_min = round(pace_time_hr * 60, 2)


pace_time_sec = round(pace_time_min % 1,2) * 60


response2 = "Average pace per mile = {} minutes and {} seconds".format(int(pace_time_min), int(pace_time_sec))


print(response2)

bottom of page