Program to calculate the product of a NumPy array

In this python numpy program, we will calculate the product of a NumPy array.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Calculate the product of the given array using prod().
  4. 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
				
			

check whether an array is empty.

convert an array into a CSV file.

Leave a Comment