题解 | 点积计算器
点积计算器
https://www.nowcoder.com/practice/e8b40a6346854c988672510a576ff8b3
import numpy as np def calculate_dot_product(vec1, vec2): """ Calculate the dot product of two vectors. Args: vec1 (numpy.ndarray): 1D array representing the first vector. vec2 (numpy.ndarray): 1D array representing the second vector. Returns: float: Dot product of the two vectors. """ dot = np.dot(vec1,vec2) return dot if __name__ == "__main__": vec1 = np.array(eval(input())) vec2 = np.array(eval(input())) print(calculate_dot_product(vec1, vec2))