Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65798
| Subject | Re: Python 2.7.6 help with modules |
|---|---|
| From | Scott W Dunning <swdunning@cox.net> |
| Date | 2014-02-09 21:17 -0700 |
| References | <032F2E23-6983-4710-B087-C1771B66C3EF@cox.net> <635C857D-1F7A-4F95-B3A7-F1A3C69BF137@cox.net> <1DA52F3B-CE00-4E47-BE84-C07482966FD7@cox.net> <F4033A14-BA16-4897-9998-65D431B5071C@cox.net> <Q6YW1n0063bjUJS016YX8V> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6610.1392005882.18130.python-list@python.org> (permalink) |
[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)?
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python 2.7.6 help with modules Scott W Dunning <swdunning@cox.net> - 2014-02-09 21:17 -0700
csiph-web