我想寫一個函數sum_square_difference
它需要一個數字n並返回前n個自然數的平方之和與平方他們的總和。函數來計算平方和和平方之差
我想我知道如何編寫定義
def sum_of_squares(numbers):
total = 0
for num in numbers:
total += (num ** 2)
return(total)
我試圖實現資金功能的平方平方和的函數:
def square_sum(numbers):
total = 0
for each in range:
total = total + each
return total**2
我不知道如何結合功能來說明差異,我不知道我的功能是否正確。
有什麼建議嗎?我正在使用Python 3.3
謝謝。
不明白爲什麼這是-1'd。我爲 – TerryA 2013-03-24 09:01:56