Python function to convert seconds into minutes, hours, and days

前端 未结 16 1418
不思量自难忘°
不思量自难忘° 2020-11-28 07:27

Question: Write a program that asks the user to enter a number of seconds, and works as follows:

  • There are 60 seconds in a minute. If the number of seconds

16条回答
  •  伪装坚强ぢ
    2020-11-28 08:03

    def normalize_seconds(seconds: int) -> tuple:
        (days, remainder) = divmod(seconds, 86400)
        (hours, remainder) = divmod(remainder, 3600)
        (minutes, seconds) = divmod(remainder, 60)
    
        return namedtuple("_", ("days", "hours", "minutes", "seconds"))(days, hours, minutes, seconds)
    

提交回复
热议问题