def seconds_difference(time_1, time2): '''(float, float) -> float Return the number of seconds later that a time in seconds time_2 is than a time in seconds time_1. >>> seconds_difference(1800.0, 3600.0) 1800.0 >>> seconds_difference(3600.0, 1800.0) -1800.0 >>> seconds_difference(1800.0, 2160.0) 360.0 >>> seconds_difference(1800.0, 1800.0) 0.0 ''' def hours_difference(time_1, time_2): '''(float, float) -> float return the number of hours later that a time in seconds time_2 is than a time in seconds time_1. >>> hours_difference(1800.0, 3600.0) 0.5 >>> hours_difference(3600.0, 1800.0) -0.5 >>> hours_difference(1800.0, 2160.0) 0.1 >>> hours_difference(1800.0, 1800.0) 0.0 ''' def to_float_hours(hours, minutes, seconds): '''(int, int, int) -> float Return the total number of hours in the specified number of hours, minutes, and seconds. precondition: 0 <= minutes < 60 and 0 <= seconds < 60 >>> to_float_hours(0, 15, 0) 0.25 >>> to_float_hours(2, 45, 9) 2.7525 >>> to_float_hours(1, 0, 36) 1.01 ''' def to_24_hour_clock(hours): '''(number) -> number hours is a number of hours since midnight. Return the hour as seen on a 24-hour clock. Precondition: hours >= 0 >>> to_24_hour_clock(24) 0 >>> to_24_hour_clock(48) 0 >>> to_24_hour_clock(25) 1 >>> to_24_hour_clock(4) 4 >>> to_24_hour_clock(28.5) 4.5 ''' return hours % 24 ### Write your get_hours function definition here: ### Write your get_minutes function definition here: ### Write your get_seconds function definition here: def time_to_utc(utc_offset, time): '''(number, float) -> float Return time at UTC+O, where utc_offset is the number of hours awar from UTC_0. >>> time_to_utc(+0, 12.0) 12.0 >>> time_to_Utc(+1, 12.0) 11.0 >>> time_to_utc(-1, 12.0) 13.0 >>> time_to_utc(-11, 18.0) 1.0 >>> time_to_utc(-1, 23.0) 0.0 ''' def time_from_utc(utc_offset, time): '''(number, float) -> float Return UTC time in time zone utc_offset. >>> time_from_utc(+0, 12.0) 12.0 >>> time_from_utc(+1, 12.0) 11.0 >>> time_form_utc(+6, 6.0) 12.0 >>> time_form_utc(-7, 6.0) 23.0 >>> time_form_utc(-1, 23.0) 22.0 >>> time_form_utc(+1, 23.0) 0.0 '''
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question