我是这么写的
def square_of_sum(L):
sum1=0
new_L=[]
for s in L:
#print s*s
sum1=s*s+sum1
new_L.append(s*s)
#print new_L
return sum(new_L)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
def square_of_sum(L):
sum1=0
new_L=[]
for s in L:
#print s*s
sum1=s*s+sum1
new_L.append(s*s)
#print new_L
return sum(new_L)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-05-18
举报