Python 2.7.6 help with modules

Scott W Dunning swdunning at cox.net
Sat Feb 8 20:21:54 EST 2014


I figured it out!  Thanks Chris!  Taking it one step at a time with the five digit number really helped me to see how to break it all up!  Are you a teacher?  I appreciate the help and the patients!  I like that you don’t just give me the answer that you break it down and help me so that I can figure it out on my own!  Thanks to all of you for all of your help, you guys are helping me a lot and I really appreciate it!

Here is how I did it if you’re curious.….

seconds = raw_input("Enter the number of seconds:")
seconds = int(seconds)
weeks = seconds/604800
weeks_rem = seconds % 604800
days = weeks_rem / 86400
days_rem = seconds % 86400
hours = days_rem / 3600
hours_rem = seconds % 3600
minutes = hours_rem / 60
minutes_rem = seconds % 60
seconds = minutes_rem % 60

print weeks, 'weeks', days, 'days', hours, 'hours', minutes, 'minutes', seconds, 'seconds'

Not sure if that’s the correct way to do it but it works!   If there is any other advice I’ll take it.  




On Feb 7, 2014, at 11:29 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Sat, Feb 8, 2014 at 5:27 PM, Scott W Dunning <swdunning at cox.net> wrote:
>> Ok, so it this what you’re talking about?
>> 
>> 
>> number = int(raw_input(“Enter a five digit number:))
>> foo = number % 10
>> bar = number / 10
>> 
>> digit = foo / 10
>> rem = bar % 10
>> 
> 
> Close! But if you print out foo and bar, you'll see that you're naming
> them backwards in the second one. The last digit is the remainder
> (modulo), the rest is the quotient.
> 
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list