完成函数fun7,参数v是一个n*m的矩阵(二维列表,每个数是0-10的整数),求出每一行中最大值与最小值差的绝对值,返回类型为Numpy数组,并返回最大的一个绝对值所在行的索引。
def fun7(v):
'''
Arg
v: a 3*3 matrix ; return the difference between the maximum and minimum of each row and number of rows with maximum difference
eg
[[3, 2, 7],
[2, 8, 4],
[9, 6, 1]]
return (array([5 6 8]), 2)
'''
#因为每个数都是0-10,所以这里不需要abs函数
diff=np.max(v,axis=1)-np.min(v,axis=1)
return (diff,int(np.where(diff==np.max(diff))[0]))