[Tutor] Find out if a number is even or not

nick at javacat.f2s.com nick at javacat.f2s.com
Fri Oct 15 13:00:18 CEST 2004


Hi group,

Im sure this is simple to do, but Ive just been looking through the python docs
and the archive of this mailing list and cant find what Im after.

I just want to know if a number is even or not.

I've had a look at the math package but that doesnt seem to have anything this
simple in it.

I thought something like

>>> if 10 div 2 == 0 : print 'even'
>>> else : print 'odd'

but obviously that doesnt work.

Sorry for such a basic question, but I really cant find out how to do this.

Kind regards
Nick.




 
-------------------------------------------------
Everyone should have http://www.freedom2surf.net/


More information about the Tutor mailing list