练习篇(Part 4) 41. How to sum a small array faster than np.sum? (★★☆) arr = np.arange(10) print(np.add.reduce(arr)) 运行结果:45 42. Consider two random array A and B, check if they are equal (★★☆) arr1 = np.random.randint(0,2,4).reshape(2,2) arr2 = np.rando…
Numpy学习之--数组创建 过程展示 import numpy as np a = np.array([2,3,9]) a array([2, 3, 9]) a.dtype dtype('int32') b = np.array([1.2,2.3,3]) b array([1.2, 2.3, 3. ]) b.dtype dtype('float64') 常见的错误是:直接将多个数值当做参数传递,正确的做法是将他们以列表或数组的方式传递 # a = np.array(1,2,3)#错误 b =…