Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

Multiplication

The multiply() function multiplies the values from one array by the values from another array and returns the results in a new array.

Example

Multiply the values in arr1 by the values in arr2:

import numpy as np

arr1 = np.array([102030405060])
arr2 = np.array([202122232425])

newarr = np.multiply(arr1, arr2)

print(newarr)
The example above will yield [200, 420, 660, 920, 1200, 1500], which results from 10×2010 \times 20, 20×2120 \times 21, 30×2230 \times 22, and so on.

Division

The divide() function divides the values in one array by the corresponding values in another array and returns the results in a new array.

Example

Divide the values in arr1 by the values in arr2:

import numpy as np

arr1 = np.array([102030405060])
arr2 = np.array([35108233])

newarr = np.divide(arr1, arr2)

print(newarr)
The example above will produce [3.33333333, 4., 3., 5., 25., 1.81818182], which results from 10/310/3, 20/520/5, 30/1030/10, and so forth.