Python Practice › NumPy Programs › Program 30

Multiply two vectors

EasyNumPy Programs · 30 of 100

Write a NumPy program to multiply two vectors element-wise.

Advertisement
Input
[4, 2, 8], [7, 3, 5]
Output
[28  6 40]

Approach

  1. * multiplies element by element.

Solution

Python
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.

More numpy programs

← All 100 NumPy Programs

Leave a Comment