You will write three functions for time on the 24-hour clock. The checker uses journeys that pass midnight and decimal hours from a calculator.
The idea. Change a clock time into minutes after midnight, add or subtract, and change back. The remainder operator % wraps the day round at minutes.
Your tasks.
minutes_since_midnight(hour, minute). Return the number of minutes.clock_after(hour, minute, extra). Return the clock time as a pair (hour, minute) after adding extra minutes, wrapping round at midnight.decimal_to_hm(x). Return a pair (hours, minutes) for a decimal number of hours such as 4.4. Round the minutes to a whole number.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…