单选题
要生成一个 3*4 的数组,并计算数组中偶数值之和,代码是?()
A.
import numpy as np
arr=np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
np.sum(arr[arr%2==0])
B.
import numpy as np
arr=np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
np.sum(arr[:,arr%2==0])
C.
import numpy as np
arr=np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
np.sum(arr[np.get(arr%2==0)])
D.
import numpy as np
arr=np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
np.sum(arr[arr.even()])
发表评论 取消回复