最后面直接写return行吗?还有这个函数的定义可以自己写吗
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([-5, 0, 5, 15, 25])
写成def sum(L):
sum=0
........
return
.......
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([-5, 0, 5, 15, 25])
写成def sum(L):
sum=0
........
return
.......
2018-09-05
举报