On Feb 8, 2014, at 11:30 PM, Chris Angelico <ros...@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)?
-- https://mail.python.org/mailman/listinfo/python-list