max_even_squared.py#
1# Do not change the code in this file
2
3def max_even_squared(nums):
4 if not isinstance(nums, (list, tuple)):
5 raise TypeError("not a list")
6
7 max_num = None
8
9 for n in nums:
10 if not isinstance(n, int):
11 raise TypeError("only integers are allowed")
12 if n % 2 == 0:
13 if max_num is None or n > max_num:
14 max_num = n
15
16 if max_num is None:
17 raise ValueError("no even numbers found")
18
19 return max_num ** 2