x=np.arange(12) a=x.reshape(3,4) print(a[0:2]) 输出结果:
举一反三
- 如下代码的输出结果是( )import numpy as npa = np.arange(12).reshape(3, 4)print(np.sum(a[[0, 2], 2:]))
- 如下代码的输出结果是( )import numpy as npa = np.arange(12).reshape(3, 4)print(np.sum(a[1:, 2:]))
- 有如下语句:import numpy as npA=np.arange(12) .reshape(3,4)则A[1]的值是[0,1,2,3]
- 已知数组arr1 = np.arange(1, 13).reshape([3, 4]),并且有arr2 = arr1[arr1[:, 2] > 2, arr1[1, :] > 5],问print(arr2)输出什么? A: [[6 7 8] [10 11 12]] B: [2 7 12] C: [1 6 11]
- a = [x for x in range(4) if x % 2 ==1],语句print(a)输出为 A: [1, 2, 3] B: [0, 1, 2, 3] C: [0, 2] D: [1, 3]