[Tutor] puzzled by Python 3's print()

Steven D'Aprano steve at pearwood.info
Fri Jul 2 01:18:27 CEST 2010


On Fri, 2 Jul 2010 05:18:00 am Eike Welk wrote:

> As you are using long integers (and you were previously writing about
> prime numbers) the precision of floating point numbers might not be
> enough for your purposes.

It certainly won't be once you get to large enough primes!

> Therefore you should probably use the integer division operator: "//"

And the reminder (or modulo) operator %, together with the combination 
function divmod(a, b) which returns (a//b, a%b). The advantage of 
divmod is that it is faster than calling a//b followed by a%b.


-- 
Steven D'Aprano


More information about the Tutor mailing list