[N00B] What's %?

Enoch Enoch at theFort.org
Fri Feb 11 12:52:44 EST 2005


administrata wrote:
> Hi! it's been about a week learning python!
> I've read 'python programming for the absolute begginer'
> I don't understand about % like...
> 
> 107 % 4 = 3
> 7 % 3 = 1
> 
> I'm confused with division :/
> Please help me...
> 
> thx 4 reading.

% means modulus, which is simply, the remainder of A divided by B
so:

7 % 3 = 1

because only two threes go into seven, leaving 1 remainder. Modulus only 
returns that remainder.

And 107 % 4 = 3 because 26 4's go into 107 leaving 3 over.

Make sense?

Enoch.



More information about the Python-list mailing list