Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    76
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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...

  • #2
    New Coder
    Join Date
    Jan 2010
    Posts
    76
    Thanks
    3
    Thanked 0 Times in 0 Posts
    nevermind i figured it out


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •