Calculate the inner/dot product of two vectors using NumPy.

In this python numpy program, we will calculate the inner/dot product of two vectors using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create two vectors using np.array().
  3. Calculate the inner/dot product of two vectors using np.dot().
  4. Print the output.
				
					import numpy as np
x = np.array([5, 3])
y = np.array([7,4])

print("Inner-dot product: ",np.dot(x,y))
				
			

Output :

				
					Inner-dot product:  47
				
			

calculate the sum of each column in an array.

add a vector to each row of a matrix.

Leave a Comment