Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python coding problem- how to convert seconds into minutes, hours, and day?

Reply
Thread Tools

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

 
 
lemonhead71 lemonhead71 is offline
Junior Member
Join Date: Oct 2012
Posts: 3
 
      10-03-2012
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to convert Seconds to X Hours Y Minutes Z Seconds? 00_CP_D12 ASP .Net 3 02-22-2008 10:37 AM
convert seconds to hours:minutes:seconds `p Ruby 7 12-14-2005 03:32 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Convert seconds to minutes and seconds tshad ASP .Net 7 03-11-2005 11:27 PM



Advertisments