[Tutor] Find out if a number is even or not
Roger Merchberger
zmerch at 30below.com
Fri Oct 15 20:56:09 CEST 2004
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
More information about the Tutor
mailing list