count_evens

Return the number of even ints in the given list. Note: the % “mod” operator computes the remainder, e.g. 5 % 2 is 1.

This exercise was taken from codingbat.com and has been adapted for the Python language. There are many great programming exercises there, but the majority are created for Java.

Test 1

Input:

[2, 1, 2, 3, 4]

Output:

3

Test 2

Input:

[2, 2, 0]

Output:

3

Test 3

Input:

[1, 3, 5]

Output:

0

Test 4

Input:

[]

Output:

0

Test 5

Input:

[11, 9, 0, 1]

Output:

1

Test 6

Input:

[2, 11, 9, 0]

Output:

2

Test 7

Input:

[2]

Output:

1

Test 8

Input:

[2, 5, 12]

Output:

2