Count Even Numbers
EasyPractice library · +10 XPbasicsloopsconditionals
Given a list of N integers, print the count of how many of them are even. An integer is even if it is divisible by 2 with no remainder.
Input
The first line contains an integer N. The second line contains N space-separated integers.
Output
Print a single integer: the count of even numbers in the list.
Constraints
1 <= N <= 1000 Each integer in the list will be between -1000 and 1000, inclusive.
Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests
Example 1
Input
5 1 2 3 4 5
Output
2
There are 2 even numbers (2 and 4) in the list.
Example 2
Input
3 10 20 30
Output
3
All 3 numbers are even.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
5 1 2 3 4 5
Example 2 input
3 10 20 30