Skip to content

Instantly share code, notes, and snippets.

@chck
Last active May 22, 2024 12:14
Show Gist options
  • Save chck/a1718d661eefdfbd052f56588dd26311 to your computer and use it in GitHub Desktop.
Save chck/a1718d661eefdfbd052f56588dd26311 to your computer and use it in GitHub Desktop.
# Calcurate km/h from distance (km) and duration (mm:ss) to manage your workout.
#
# Usage:
# python phour.py 2.62 20:28
# >> 7.68 km/h
#
from sys import argv
distance = argv[1] # 2.62 km
duration = argv[2] # 20.28 m
m, s = duration.split(':')
h = (int(m) + int(s)/60)/60
phour = round(float(distance) / h, 2)
print(f"{phour} km/h")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment