This article shows how to use the Python built-in divmod for unit conversions.
divmod
Tunnel excavation involves lots of boring mathematics.