Python Practice › NumPy Programs › Program 30
Multiply two vectors
Write a NumPy program to multiply two vectors element-wise.
Input
[4, 2, 8], [7, 3, 5]
Output
[28 6 40]
Approach
*multiplies element by element.
Solution
import numpy as npprint(np.array([4, 2, 8]) * np.array([7, 3, 5]))Output
[28 6 40]
Learn the concept
New to this topic? Read the lesson, then come back.