[N00B] What's %?

Harlin harlinseritt at yahoo.com
Thu Feb 10 18:02:25 EST 2005


In the mode of anticipating another question... I get these all the
time at work of all places! You'd think IT workers would know the
answer to these...

What good is the modulus operator? What would I ever need it for?

* A quick way of testing whether an integer is even and odd
* For that matter, a quick way of testing whether a the variable is a
factor of any other arbitrary number.
* In some programs (a weight control program I worked on comes to mind)
it's necessary to get a remainder so that you can get the results of a
leftover evenly divisible number.

Regards,

Harlin


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.




More information about the Python-list mailing list