Help with some python homework...

Chris Angelico rosuav at gmail.com
Fri Jan 31 03:30:24 EST 2014


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



More information about the Python-list mailing list