All changes saved to local database
ML - discrete structures
Instructions

Problem Description

You have been hired by a wearable technology startup to develop the core logic for a new digital smartwatch. The watch's hardware tracks time in a single, continuous stream of total seconds elapsed since the start of the day.

Your task is to write a function that takes this large integer of seconds and converts it into a human-readable "Digital Clock" format: HH:MM:SS.

The Scenario

Imagine the watch sensor sends the value 3661.

  • 3600 seconds make up 1 hour.
  • The remaining 61 seconds contain 1 minute.
  • The final remaining 1 second is left over.
  • The final display should be: 01:01:01.

Technical Requirements

  1. Hours (HH): Calculated from the total seconds.
  2. Minutes (MM): Calculated from the seconds remaining after hours are extracted.
  3. Seconds (SS): The final remaining seconds after minutes are extracted.
  4. Formatting: The output must be a string in the format HH:MM:SS. Each unit must be two digits (e.g., 5 minutes becomes 05).

💡 Pro-Tip: Use Floor Division (//) to find the whole units and the Modulo operator (%) to find the remainders.

Examples

Example 1:

# Input seconds = 0 # Output "00:00:00"

Example 2:

# Input seconds = 59 # Output "00:00:59"

Constraints

  • 0 <= seconds <= 86399 (Total seconds in one 24-hour day).
  • The input will always be a non-negative integer.
solution.py
Terminal