Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > Python

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
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
Old 10-03-2012, 05:25 PM   PM User | #2
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
nevermind i figured it out
metathirteen is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:21 PM.


Advertisement
Log in to turn off these ads.