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

前端 未结 16 1387
不思量自难忘°
不思量自难忘° 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 07:54

    def convertSeconds(seconds):
        h = seconds//(60*60)
        m = (seconds-h*60*60)//60
        s = seconds-(h*60*60)-(m*60)
        return [h, m, s]
    

    The function input is a number of seconds, and the return is a list of hours, minutes and seconds which that amount of seconds represent.

提交回复
热议问题