【发布时间】:2020-03-31 19:03:34
【问题描述】:
【问题讨论】:
-
请提供更多你需要的例子,同时添加你现在得到的。
【问题讨论】:
def squared(numbers):
return sum(i*i for i in numbers)
【讨论】:
numbers = [10,22,33, 54 ] # we declare a list of numbers
import numpy as np # we import the library "numpy" and we name it 'np',
np.array(numbers).sum() # here we declace a numpy array and we applicate the sum function
或
sum(numbers) # this is a simple exemple of using 'sum' function with a simple array
将 numpy 导入为 np 定义平方(X): y = np.array(X)**2 返回y
【讨论】: