Answer:
We have the Python code below with appropriate comments
Step-by-step explanation:
#defining the function for use
def sumSquares(aList):
#checking if element in list is not in number as an error
if type(aList) is not list:
return 'error'
sum = 0
for x in aList:
#checking if in list and is
#divisible by 3
if type(x) in [int, float] and x % 3 == 0:
#squares of number x is x*x
#+= is an updating syntax that represents
#the sum of the squares
sum += x*x
#returning the sum, not printing
return sum
Sample test cases
print(sumSquares(5))
print(sumSquares('5'))
print(sumSquares(6.15))
print(sumSquares([1, 5, -3, 5, 9, 8, 4]))
print(sumSquares(['3', 5, -3, 5, 9.0, 8, 4, 'Hello']))
NOTE: Use in your code and view the result