This content originally appeared on CodeSource.io and was authored by Deven
In this article, you will learn how to multiply array by scalar in python.
Let’s say you have 2 arrays that need to be multiplied by scalar n
.
array1 = np.array([1, 2, 3])
array2 = np.array([[1, 2], [3, 4]])
n = 5
Numpy multiply array by scalar
In order to multiply array by scalar in python, you can use np.multiply()
method.
import numpy as np
array1 = np.array([1, 2, 3])
array2 = np.array([[1, 2], [3, 4]])
n = 5
np.multiply(array1,n)
np.multiply(array2,n)
The post How to multiply array by scalar in python appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Deven

Deven | Sciencx (2021-03-12T08:32:20+00:00) How to multiply array by scalar in python. Retrieved from https://www.scien.cx/2021/03/12/how-to-multiply-array-by-scalar-in-python/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.