This program gets the series of numbers from the user, then saves it to the array.
The array is processed using “for” loop to check each element.
If the number is even, add +1 to the value of ecount, else add +1 to the value of ocount variables.
To check whether the number is even or odd, we are using % (modulo) operator. If a number is divided by 2, if the reminder is 0, then it is an even number.
from array import * n=int(input("Enter the number of terms: ")) num=array('i',) for i in range(0,n): v=int(input("Enter the number ")) num.insert(i,v) ecount=0 ocount=0 for i in range(0,n): if (num[i] % 2) == 0: ecount+=1 else: ocount+=1 print("The number of odd numbers in the series is ",ocount) print("The number of even numbers in the series is ",ecount)