1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| import numpy as np data1 = np.array([1, 2, 3, 4, 5]) data2 = np.array([[1, 2], [3, 4]]) print(data1) print(data2)
print(data1.shape, data2.shape)
print(np.zeros([2, 3])) print(np.ones([2, 2]))
data2[1, 0] = 5 print(data2)
print(data2[1, 1]) print(data2[1][1])
data3 = np.ones([2, 3]) print(data3*2) print(data3/3) print(data3+3) print(data3-3)
data4 = np.array([[1, 2, 3], [4, 5, 6]]) print(data3+data4) print(data3 * data4)
|