Format a recording duration
Turn a nonnegative whole number of seconds into a string in H:MM:SS format.
Integer division · divmod · Formatted strings
THE PRACTICE LIBRARY
Practice Python in your browser with real tests. Format recording durations, work with strings and collections, and build up to more advanced exercises.
No account needed. Progress and drafts are saved on this device.
A recording length is a duration, not a time of day. Separate a total number of seconds into hours, minutes, and seconds. Keep hours above 23 instead of wrapping to a new day. Formatting and arithmetic are separate parts of this problem: minutes and seconds always need two digits.
Turn a nonnegative whole number of seconds into a string in H:MM:SS format. Hours have no leading zero and may exceed 23. Minutes and seconds must each use two digits. For example, 61 becomes "0:01:01". The argument is always an integer, not a boolean.
90061 secondsExpected result"25:01:01"Write your answer in the editor, then choose Run tests. Each check shows what was expected and what your code returned. Reveal hints one at a time; the solution stays behind the solution button.
Open format a recording durationTurn a nonnegative whole number of seconds into a string in H:MM:SS format.
Integer division · divmod · Formatted strings
Return a list showing the change from each reading to the reading immediately before it: current minus previous.
Lists · Indexing · None
A profile may contain nickname, full_name, and username.
Dictionaries · dict.get · String methods
Given a list of unique column-name strings and a list of values, return a dictionary that pairs each column with the value at the same position.
Dictionaries · enumerate · Positional data
Parse CSV text into a list of dictionaries, using the first row as field names and keeping data rows in their original order.
csv.DictReader · Standard library · Text parsing
Compare current permission names with target permission names.
Sets · Set difference · Sorting
Given events of the form {"date": "YYYY-MM-DD", "count": integer}, return one {"date", "count"} dictionary for every date from start_date through end_date, inclusive and ascending.
datetime.date · timedelta · Dictionaries · Date ranges
options is a list of {"name": string, "values": [strings]} objects.
itertools.product · zip · Dictionaries
Given a list of status strings, replace each consecutive run of equal statuses with {"status": string, "count": integer}.
itertools.groupby · Iteration · Run-length encoding
Combine a list of configuration dictionaries from left to right, with later layers taking precedence.
Recursion · Dictionary merging · copy.deepcopy
links is a list of directed [from_node, to_node] pairs with string node names.
Breadth-first search · collections.deque · Sets · Tie-breaking
tests is a list of {"id": string, "features": [strings]} objects with unique ids.
itertools.combinations · Sets · Exhaustive search · Deterministic ties