Computer Science, asked by hazoorbuxgaad772, 3 months ago

python
Write a program which counts the even and odd numbers of given list (you may create your own list of 20 integers)​

Answers

Answered by aryanreddy463
0

Answer:

Explanation:

list1=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

sum1=0

sum2=0

for i in list1:

if(i%2==0):

i+=1

sum1+=i

else:

i+=1

sum2+=i

print(sum1)

print(sum2)

Answered by ishaanthegreat293
0

Answer:

arr = [87, 8, 45, 28, 20, 3, 27, 39, 90, 86, 32, 71, 29, 76, 9, 39, 69, 16, 29, 23]

odds = [elem for elem in arr if elem % 2]

evens = [elems for elems in arr if not elem % 2]

print("There are {} odds and {} evens".format(len(odds), len(evens))

Similar questions