Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 3rd, 2012, 09:55 PM
sght sght is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 4 sght User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 48 sec
Reputation Power: 0
Help! Need help Creating program

Hi Everyone, I am new here, and I was hoping to get a bit of help from anyone who could give me a hand with this program. I am having a hard time wrapping my head around it. I am going to want to use while loops to do the following:

Accept two times, in 24-hour notation (e.g. 2359 = 1 minute to midnight) and then print the time difference. For example, if time1 = 1215 and time2 = 1436 the difference is 2 hours 21 minutes. If time1 = 2230 and time2 = 0415 the difference is 5 hours 45 minutes.

I would really appreciate any help

Reply With Quote
  #2  
Old December 4th, 2012, 12:39 PM
leeuw01 leeuw01 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 16 leeuw01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 51 m 50 sec
Reputation Power: 0
Quote:
Originally Posted by sght
Hi Everyone, I am new here, and I was hoping to get a bit of help from anyone who could give me a hand with this program. I am having a hard time wrapping my head around it. I am going to want to use while loops to do the following:

Accept two times, in 24-hour notation (e.g. 2359 = 1 minute to midnight) and then print the time difference. For example, if time1 = 1215 and time2 = 1436 the difference is 2 hours 21 minutes. If time1 = 2230 and time2 = 0415 the difference is 5 hours 45 minutes.

I would really appreciate any help


I don't know exactly how to do it neither, but take a look at the time module, it may help you further. http://docs.python.org/3.3/library/time.html

Reply With Quote
  #3  
Old December 4th, 2012, 08:16 PM
sght sght is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 4 sght User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 48 sec
Reputation Power: 0
I actually ended up getting it late last night. Thanks

def getime(x):

s = raw_input('Enter time-%s (hh:mm): ' % x) # I used rawinput instead.
sh, sm = s.split(':')
return int(sm) + 60 * int(sh)

time1 = getime('1')
time2 = getime('2')

diff = time2 - time1

print "Difference: %d hours and %d minutes" % (diff//60, diff%60)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Help! Need help Creating program

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap