- 1
Given a set of 100 numbers write an algorithm to find the total number of even and odd numbers in the list. Also find their sum
3 Antworten
+ 3
Welcome to the SoloLearn forum, Vedant Joshi!
Please read through our guidelines before posting:
https://www.sololearn.com/discuss/1316935/?ref=app
What language are you referring to? What have you tried so far? Please provide a link to your code so far, so that we can see where you are struggling.
0
s=[1, 2,.......,100]
sum1=0
sum2=0
c1=0
c2=0
for i in s:
if i%2==0:
c1+=1
sum1+=i
else:
c2+=1
sum2+=1
print(sum1, c1, sum, c2)
You can also shorten the code... To get a cleat idea I wrote like this...