Last active
May 30, 2020 19:46
-
-
Save pythrick/b4a4cd4227b251e7c1ddc6791d691406 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from datetime import timedelta | |
| def converter_em_segundos(hora: int = 0, minutos: int = 0, segundos: int = 0) -> float: | |
| """Função para converter hora, minutos e segundos em segundos.""" | |
| return timedelta(hours=hora, minutes=minutos, seconds=segundos).total_seconds() | |
| if __name__ == "__main__": | |
| assert converter_em_segundos(hora=1) == 3600.0 | |
| assert converter_em_segundos(minutos=1) == 60.0 | |
| assert converter_em_segundos(hora=1, minutos=1) == 3660.0 | |
| assert converter_em_segundos(hora=5, minutos=45, segundos=90) == 20790.0 | |
| assert converter_em_segundos(minutos=0.5) == 30.0 | |
| assert converter_em_segundos(hora=0.5) == 1800.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment