1.
import numpy as np
# Set the dimensions of the array
rows = 5
cols = 4
# Create the 2D array with random integers between 1 and 100
array = np.random.randint(1, 101, size=(rows, cols))
print(array)
2.
import numpy as np
# Create a 2D array with random integers between 1 and 100
array = np.random.randint(1, 101, size=(5, 4))
# Calculate the sum
sum_array = np.sum(array)
# Calculate the mean
mean_array = np.mean(array)
# Calculate the median
median_array = np.median(array)
# Calculate the standard deviation
std_array = np.std(array)
print("Array:\n", array)
print("Sum:", sum_array)
print("Mean:", mean_array)
print("Median:", median_array)
print("Standard Deviation:", std_array)
3.
import numpy as np
# Create a 2D array with random integers between 1 and 100
array = np.random.randint(1, 101, size=(5, 4))
# Find the index of the maximum value
max_index = np.unravel_index(np.argmax(array), array.shape)
# Find the index of the minimum value
min_index = np.unravel_index(np.argmin(array), array.shape)
print("Array:\n", array)
print("Index of maximum value:", max_index)
print("Index of minimum value:", min_index)
4.
import numpy as np
# Create a 2D array with random integers between 1 and 100
array_2d = np.random.randint(1, 101, size=(6, 4))
# Reshape the 2D array into a 3D array
array_3d = array_2d.reshape((2, 3, 4))
# Create another 3D array with the same shape
array_3d_2 = np.random.randint(1, 101, size=(2, 3, 4))
# Perform element-wise multiplication
result = np.multiply(array_3d, array_3d_2)
print("Original 2D Array:\n", array_2d)
print("Reshaped 3D Array:\n", array_3d)
print("Second 3D Array:\n", array_3d_2)
print("Result of Element-wise Multiplication:\n", result)