max_even_square.py

max_even_square.py#

 1# The code below is supposed to find the maximum even number in a list and return its square
 2numbers = [3, 7, 2, 8, 5, 10, 6]
 3
 4def max_even_square(nums):
 5    max_num = 0
 6    for n in nums:
 7        if n % 2 == 1: 
 8            if n > max_num:
 9                max_num = n
10    square = max_num * 2 
11    return square
12
13print("The max even number squared is:", max_even_square(numbers))