...

# cant figure this out

metathirteen
10-03-2012, 04:31 PM
basically its giving me what the function is for and what the hours, minutes, and seconds as a float should look like when its returned, but i have to program what gets me to the answer and im having the hardest time. i know im on the right track, but i think im screwing up the seconds part... could anybody help me out?

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
'''
return hours + minutes / 60 + (seconds * hours/120)

hours come in as whole numbers, so like 1 hour is 1, 2 hours is 2. minutes come up as the faction of the hour. so 15 minutes is 25, 30mins is 0.5. but i think im messing up the seconds horribly...

metathirteen
10-03-2012, 06:25 PM
nevermind i figured it out