负数计算没起到效果,两个结果一样
def square_of_sum(L):
sum = 0
for x in L:
sum = sum + x*x
return sum
print(square_of_sum([1,2,3,4,5]))
print(square_of_sum([-1,-2,-3,4,5]))
def square_of_sum(L):
sum = 0
for x in L:
sum = sum + x*x
return sum
print(square_of_sum([1,2,3,4,5]))
print(square_of_sum([-1,-2,-3,4,5]))
2017-03-20
举报