[Tutor] Find out if a number is even or not
Riumu Kuraku
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
variables,
and I've still got to comprehend 'if not' statements.
Regards,
Liam Clarke
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:
> >[snip]
> >Be cool and write your own function for this...
> >
> >def OddorEven(x):
> >a=0
> >a=x % 2
> >if a ==0:
> > return "Even"
> >else:
> > 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"
> else:
> return "Even"
>
> [[ Oh, and your indentation was a schootch off... ;-) ]]
>
> HTH,
> 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
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list