Ad Code

Write a NumPy program to create a 3x3x3 array with random values and find the sum

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)


Reactions

Post a Comment

0 Comments