

InterviewSolution
Saved Bookmarks
1. |
Find display the sum of even and odd numbers among 10 numbers |
Answer» # total SUM esum=None # even sum osum=0 # odd sum for n in NUMBERS: #if you don't have the numbers already you #can get them in the loop instead: #for i in RANGE(10): # n=getNumber() # than continue as in this loop tsum+=n if n%2==0: if esum==None: esum=n ELSE: esum+=n else: osum+=n |
|