创建一个x形(5,6)的数组,其中有30个在-30和30之间的随机整数
print the cumulative sum of x along axies 0
print the cumulative sum of x along axies 1
期望的输出是9和-32。
我尝试了下面的代码
import numpy as np
np.random.seed(100)
l1= np.random.randint(-30,30, size=(5,6))
x= np.array(l1)
print(x.sum(axis=0))
print(x.sum(axis=1))
能告诉我这是怎么回事吗?
2条答案
按热度按时间wfypjpf41#
表达式的结果是:
正如你所写的,预期结果是 9 和 -32,也许你想计算最后一列和最后一行的总和?
为了得到这些结果,计算:
93ze6v8z2#
import numpy as np
def array_oper(num1,num2):