Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON : Write a function countEvens() that takes a two-dimensional list of inte

ID: 3667784 • Letter: P

Question

PYTHON : Write a function countEvens() that takes a two-dimensional list of integers as a parameter and returns the number of elements in the list that are even A number is even if it is evenly divisible by 2. If there are no even numbers in the list, then the function should return 0. The following shows several sample runs of the function:

Python Shell File Edit Shell Debug Options Windows Help >>> countEvens , 4, 31, 12, 0,7, 10, 31, [13]1) >>> countEvens 25,4, [1, 2, 3, 4, 51, [0, 50, 991]) >>> COuntEvens1 3] [5]1] >>> COuntEvens) Ln: 13 Col:

Explanation / Answer

def countEvens(lst):
   count=0
   for row in lst:
       for column in row:
           if column%2==0:
               count++
   return count