- 4
I don't get this at all !!! Pls someone take a look at it
Write a function that takes the number of seconds (non-negative integer) and returns the list of four non-negative integers as follows: The first element represents. The number of days. The second element represents. The number of hours. The third element represents. The number of minutes. The fourth element represents. The number of seconds. Make sure that in the return list: 0 <= seconds <60 0 <= minutes <60 0 <= hours <24 The input contains. The number of seconds. List output to high profile. Sample Input Example 1. 610. Copy Sample Output 1 [0, 0, 10, 10] Copy Sample Input 2 100000. Copy Sample Output 2 [1, 3, 46, 40]
4 odpowiedzi
+ 2
Please show us your attempt first.
+ 2
What part are you not understanding? Let us know if this helps.
1. Accept an integer input which will be the total number of seconds
2. Break down the number of seconds into an array of integers by days, hours, minutes, and seconds.
3. Return the array.
+ 1
# what is so complicated about it:
# it is just math ...
# you can use also divmod()
a = int(input())
mins,secs = a//60,a%60
hours,mins = mins//60,mins%60
days,hours = hours//24,hours%24
print(days,hours,mins,secs)
0
Thanks I got it