Help with some python homework...

Scott W Dunning swdunning at cox.net
Sat Feb 1 01:42:15 CET 2014


Also, any help on how to get the hours and seconds into double digits that would be cool too.  00:00:00

On Jan 31, 2014, at 1:30 AM, Chris Angelico <rosuav at gmail.com> wrote:

> On Fri, Jan 31, 2014 at 7:17 PM, Gregory Ewing
> <greg.ewing at canterbury.ac.nz> wrote:
>> sjud9227 wrote:
>>> 
>>> Doesn't
>>> assigning seconds/(60*60) mean that calculating 6*hours will give me 6
>>> hours
>>> in seconds?
>> 
>> No, it's giving you 6 seconds in hours. (That should
>> give you a clue as to what you should have done
>> instead. :-)
>> 
>> ...
>> 
>>   a // b gives the quotient of dividing a by b
>> 
>>   a % b gives the remainder
>> 
>> (I recommend using '//' rather than just '/', because
>> in some versions of Python, a/b does floating point
>> division even if a and b are both integers, and that's
>> not what you want here.)
> 
> OP is using 2.7.6, so short of a __future__ directive, that won't
> actually give 6 seconds in hours (though it will try to), and // is
> unnecessary.
> 
> ChrisA
> -- 
> https://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list