View Single Post
Old 10-03-2012, 03:31 PM   PM User | #1
metathirteen
New Coder

 
Join Date: Jan 2010
Posts: 76
Thanks: 3
Thanked 0 Times in 0 Posts
metathirteen is an unknown quantity at this point
cant figure this out

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?


Code:
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 is offline   Reply With Quote