Functions · 26 / 27 Exercise Easy

Seconds to hours and minutes

Objective

A function can return several values at once: it actually returns a tuple, which can be unpacked into several variables when calling it.

Instructions

  • Define split_time(seconds) that receives a number of seconds and returns the three values (hours, minutes, seconds) (you can use divmod).
  • Read n and then n numbers of seconds, one per line.
  • For each one, receive the three values by unpacking them and show HH:MM:SS with two digits in each part (for example 01:01:01).
Input
3
3661
59
86399
Output
01:01:01
00:00:59
23:59:59

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise