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
    Likes Received:
    0
    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. Advertisements

  2. lemonhead71

    UoPTucson

    Joined:
    Jun 28, 2017
    Messages:
    5
    Likes Received:
    2
    Your function is returning a tuple, not a single value.
     
    UoPTucson, Jul 3, 2017
    #2
    1. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. tshad
    Replies:
    7
    Views:
    19,739
    tshad
    Mar 11, 2005
  2. 00_CP_D12
    Replies:
    3
    Views:
    9,759
    dilipv
    Feb 22, 2008
  3. Stu
    Replies:
    7
    Views:
    2,296
    Dave Thompson
    Mar 7, 2005
  4. `p
    Replies:
    7
    Views:
    851
    Steve Litt
    Dec 14, 2005
  5. brewhousepdx

    how to convert wordpress template into Html

    brewhousepdx, Dec 29, 2016, in forum: HTML and CSS
    Replies:
    0
    Views:
    242
    brewhousepdx
    Dec 29, 2016
  6. Rohini
    Replies:
    0
    Views:
    231
    Rohini
    Feb 23, 2017
  7. SUser
    Replies:
    1
    Views:
    247
    kyrericard
    Apr 24, 2017
  8. AtomicBunny

    Im looking to learn how to code.

    AtomicBunny, Jul 1, 2017, in forum: C Programming
    Replies:
    2
    Views:
    92
    Thiefcom
    Jul 2, 2017
Loading...