python coding problem- how to convert seconds into minutes, hours, and day?

Discussion in 'Python' started by lemonhead71, Oct 3, 2012.

  1. lemonhead71

    lemonhead71

    Joined:
    Oct 3, 2012
    Messages:
    3
    I would like to create a program to convert seconds into minutes, hours, and day in python.

    my function:

    def time_values(total_seconds):
    number_of_minutes=total_seconds//60
    number_of_hours=total_seconds//3600
    number_of_days=total_seconds//86400
    return number_of_minutes, number_of_hours, number_of_days

    in another module:

    seconds=int(input('Enter the number of seconds:').strip())
    minutes=q2_functions.time_values(seconds)
    hours=q2_functions.time_values(seconds)
    days=q2_functions.time_values(seconds)
    print('{0} seconds is equal to {1} minute(s), {2} hour(s), and {3} day(s).'.format(seconds,minutes,hours,days))


    These are the outputs I got:
    Enter the number of seconds:86400
    86400 seconds is equal to (1440, 24, 1) minute(s), (1440, 24, 1) hour(s), and (1440, 24, 1) days(s)

    These are the outputs I want:
    86400 seconds is equal to 1440 minute(s), 24 hour(s), and 1 day(s).

    What am I doing wrong? Thanks for your help.
    lemonhead71, Oct 3, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    7
    Views:
    16,970
    tshad
    Mar 11, 2005
  2. 00_CP_D12
    Replies:
    3
    Views:
    8,911
    dilipv
    Feb 22, 2008
  3. Stu
    Replies:
    7
    Views:
    1,755
    Dave Thompson
    Mar 7, 2005
  4. Eric

    Time Format in datagrid (Hours, Minutes, Seconds)

    Eric, Aug 12, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    285
    Alvin Bruney [MVP]
    Aug 12, 2004
  5. `p
    Replies:
    7
    Views:
    370
    Steve Litt
    Dec 14, 2005
Loading...

Share This Page