
Patrick B. answered 02/09/21
Math and computer tutor/teacher
def SumOfSquares(x):
if len(x)>0:
return x[0]*x[0]+SumOfSquares(x[1:])
else:
return 0
x=[1, 7, 8, 6, 11]
sum = SumOfSquares(x)
print(sum)
Jessie M.
asked 02/09/21Question Info:
The calculation "a" was
used for loop to calculate the sum of squares of values in this list: 1, 7, 8, 6, 11 (The answer was 271)
Question To Answer:
(1) Create recursive function to do the same calculation a in the above. (The function input will be the list. Each recursion, you are going to send a sub-list with one less item from the list)
I need help doing this in python programming language.
Patrick B. answered 02/09/21
Math and computer tutor/teacher
def SumOfSquares(x):
if len(x)>0:
return x[0]*x[0]+SumOfSquares(x[1:])
else:
return 0
x=[1, 7, 8, 6, 11]
sum = SumOfSquares(x)
print(sum)
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.