[Tutor] Integer?

Bob Gailer bgailer at alum.rpi.edu
Fri Dec 15 20:15:29 CET 2006


Kent Johnson wrote:
> A better way to check for divisibility is to use the modulo operator % 
> which gives the remainder when one number is divided by another. 
Only when the left argument is positive does it give the remainder. The 
manual is in error when it says remainder, but the algorithm it gives is 
correct.
> If a % 
> b == 0 then b is a factor of a.
>
> Kent
>
>   
>> On 12/5/06, *Kent Johnson * <kent37 at tds.net <mailto:kent37 at tds.net>> wrote:
>>
>>     Eli Zabielski wrote:
>>      > How can I check if a variable is an integer?
>>
>>     Luke and John have answered your question, but we should also ask, why
>>     do you want to do that? Explicit type testing is a code smell, perhaps
>>     there is a better way to do what you want.
>>
>>     Kent
>>
>>
>>
>>
>> -- 
>> Eli Zabielski
>>     
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>   


-- 
Bob Gailer
510-978-4454



More information about the Tutor mailing list