[Tutor] How to test for a remainder from division

Alan Gauld alan.gauld at btinternet.com
Tue May 15 01:11:54 CEST 2007

"Bob Gailer" <bgailer at alum.rpi.edu> wrote

>> Matt:  I'm not sure about your pseudocode, but have you tried to
>> accomplish this with the modulus operator?
>> It provides the remainder of integer division
> No, it provides the modulus, and applies to float not just integer!.

While modulus is technically correct I prefer to use the
term modulo since modulus can also be used to mean the
magnitude or absolute value of a number. i.e. its true to say
that abs(-7) provides the modulus of -7 (i.e. 7) which is different
to the modulo - which is a binary operator...

But one of the nice things about Python is that, whatever we
call it, Python does it correctly! :-)

Alan G. 

More information about the Tutor mailing list