Last active
September 14, 2016 20:25
-
-
Save dnorton/963e57536dab6a2b437f1658eb0118f5 to your computer and use it in GitHub Desktop.
python script to calculate average pace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Script to add up minutes:seconds and give average pace""" | |
def sum_times(*times): | |
'''arg list of MM:SS''' | |
return sum(map(lambda x: int(x.split(':')[0]) * 60 + int(x.split(':')[1]), times)), len(times) | |
def secs_to_mins(seconds, count): | |
print "total time: {0:02d}:{1:02d}".format(seconds / 60, seconds % 60) | |
print "Average pace {0:02d}:{1:02d}".format((seconds/count) / 60, (seconds/count) % 60) | |
if __name__ == "__main__": | |
ts, count = sum_times("7:30", "6:05") | |
secs_to_mins(ts, count) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment