Q:

Write a NumPy program to sum and compute the product of a NumPy array elements

0

Write a NumPy program to sum and compute the product of a NumPy array elements

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.array([10, 20, 30], float)
print("Original array:")
print(x)
print("Sum of the array elements:")
print(x.sum())
print("Product of the array elements:")
print(x.prod())

Sample Output:

Original array:                                                                   
[ 10.  20.  30.]                                                                
Sum of the array elements:                                                          
60.0                                                                       
Product of the array elements:                                                      
6000.0

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now