Write a NumPy program to create a 3x3x3 array with random values and find the sum.
Code:
import numpy as np
# Create a 3x3x3 array with random values
array_3d = np.random.rand(3, 3, 3)
# Find the sum of all elements in the array
array_sum = np.sum(array_3d)
print("3x3x3 Array with Random Values:")
print(array_3d)
print("\nSum of all elements in the array:", array_sum)
0 Comments