[Tutor] Find out if a number is even or not
cyresse at gmail.com
Sat Oct 16 00:34:27 CEST 2004
Hehe, yeah, it was a roughy, I've only been doing this for one week myself.
the first assignment of 0 is just me being paranoid about non-assigned
and I've still got to comprehend 'if not' statements.
On Fri, 15 Oct 2004 14:56:09 -0400, Roger Merchberger
<zmerch at 30below.com> wrote:
> Rumor has it that Riumu Kuraku may have mentioned these words:
> >Be cool and write your own function for this...
> >def OddorEven(x):
> >a=x % 2
> >if a ==0:
> > return "Even"
> > eturn "Odd"
> Just to let you know:
> The first assignment of 0 to a seems superfluous as you're reassigning it
> in the very next statement; and just to show others a different way of
> coding this...
> def OddorEven(x):
> a=x % 2
> if a:
> return "Odd"
> return "Even"
> [[ Oh, and your indentation was a schootch off... ;-) ]]
> Roger "Merch" Merchberger
> Roger "Merch" Merchberger | JC: "Like those people in Celeronville!"
> sysadmin, Iceberg Computers | Me: "Don't you mean Silicon Valley???"
> zmerch at 30below.com | JC: "Yea, that's the place!"
> | JC == Jeremy Christian
> Tutor maillist - Tutor at python.org
More information about the Tutor