Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65798 > unrolled thread

Re: Python 2.7.6 help with modules

Started byScott W Dunning <swdunning@cox.net>
First post2014-02-09 21:17 -0700
Last post2014-02-09 21:17 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Python 2.7.6 help with modules Scott W Dunning <swdunning@cox.net> - 2014-02-09 21:17 -0700

#65798 — Re: Python 2.7.6 help with modules

FromScott W Dunning <swdunning@cox.net>
Date2014-02-09 21:17 -0700
SubjectRe: Python 2.7.6 help with modules
Message-ID<mailman.6610.1392005882.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

On Feb 8, 2014, at 11:30 PM, Chris Angelico <rosuav@gmail.com> wrote:

I have one more question on this if you don’t mind.  I’m a bit confused on how it works this way without it being in seconds?  I’ll answer below each step of how it seems to work to me.

> How to do it from the small end up:
> 
> time = int(raw_input("Enter number of seconds: "))
> seconds = time % 60
So here it takes say 1000000 and divides it by 60 to put in seconds and spits out the remainder?  1000000 / 60 is approximately 16666 with a remainder of about 40, which would be the correct amount for seconds.  From there I get a little lost.

> time /= 60
Then we take the remainder (40) from above and divide that by 60?  Already it’s confusing me.  

> minutes = time % 60
Are we still using the new number from above for time and dividing that by 60 and using the remainder for minutes?  

> time /= 60

Then taking the remainder from the line above and so on and so on…?

> hours = time % 24
> time /= 24
> days = time % 7
> time /= 7
> weeks = time
> # Alternative way to format for display:
> print("%d weeks, %d days, %02d:%02d:%02d"%(weeks,days,hours,minutes,seconds))
> 
Also, would it work the same way with smaller divisors the other way around (from weeks - seconds)?








[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web