import numpy as np
if __name__ == '__main__':
print(np.__version__)
vec = np.array([1, 2, 3])
print(vec)
vec[0] = '111'
print(vec) # [111 2 3]
# vec[0] = 'a'
# print(vec) # ValueError: invalid literal for int() with base 10: 'a'
print(np.zeros(3)) # [0. 0. 0.]
print(np.ones(3)) # [1. 1. 1.]
print(np.full(2, 3)) # [3 3]
print(vec.size)
print(len(vec))
print(vec[0])
print(vec[-1])
print(vec[0:])
print(type(vec)) # <class 'numpy.ndarray'>
vec2 = np.array([1, 2, 3])
print(vec + vec2)
print(vec - vec2)
print(vec * vec2) # [111 4 9]
print(2 * vec2) # [2 4 6]
print(vec * 2)
print(np.linalg.norm(vec)) # 模 111.05854312028409
print(vec / np.linalg.norm(vec)) # 归一化 #[0.99947286 0.01800852 0.02701278]
print(np.linalg.norm(vec / np.linalg.norm(vec))) # 1.0
print(np.zeros(3) / np.linalg.norm(vec)) # [0. 0. 0.]