[ create a new paste ] login | about

Link: http://codepad.org/ps9eYIhT    [ raw code | output | fork ]

Python, pasted on Oct 9:
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
    '''

    return(round((time_2/3600) - (time_1/3600) ,1))

print hours_difference(1800.0, 1800.1)
print hours_difference(1800.1, 1800.0)
print hours_difference(1800.0, 3600.0)
print hours_difference(3600.0, 1800.0)


Output:
1
2
3
4
0.0
-0.0
0.5
-0.5


Create a new paste based on this one


Comments: