Nat*_*ate -11 python iteration computer-science list
写一个函数sum_of_squares(xs)来计算列表xs中数字的平方和.例如,sum_of_squares([2, 3, 4])应返回4 + 9 + 16,即29:
sum_of_squares([2, 3, 4])
29
ins*_*get 10
这是一个不错的单线
sum_of_squares = lambda L : sum(map(lambda iGotThisFromStackOverflow:iGotThisFromStackOverflow**2, L))
归档时间:
11 年,6 月 前
查看次数:
656 次
最近记录:
10 年,4 月 前