In this python numpy program, we will calculate the product of a NumPy array.
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array().
- Calculate the product of the given array using prod().
- Print the output.
import numpy as np
x = np.array([3, 5, 1])
print("Product of the elements in the given array: ",x.prod())
Output :
Product of the elements in the given array: 15