
Feb. 20, 2002
8:38 p.m.
I have a question of style and am wondering if you would consider giving some feedbakc. Let's say you have a task of finding out how many of 5 positive integer numbers (a-e) are even. Which (if either) of the two codes would be preferred: # {option A} odd=a%2+b%2+c%2+d%2+e%2 even=5-odd # {option B} if a%2==0: even = even + 1 if b%2==0: even = even + 1 if c%2==0: even = even + 1 if d%2==0: even = even + 1 if e%2==0: even = even + 1 odd = 5 - even Is option A guilty of relying on the "side effect" of mod 2 being a 1 or zero or is this a desireable/understandable use of this function's return value? /c
8420
Age (days ago)
8420
Last active (days ago)
0 comments
1 participants
participants (1)
-
Christopher Smith