Q:

Write a NumPy program to get the minimum and maximum value of a given array along the second axis

0

Write a NumPy program to get the minimum and maximum value of a given array along the second axis.

All Answers

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

import numpy as np
x = np.arange(4).reshape((2, 2))
print("\nOriginal array:")
print(x)
print("\nMaximum value along the second axis:")
print(np.amax(x, 1))
print("Minimum value along the second axis:")
print(np.amin(x, 1))

Sample Output:

Original array:
[[0 1]
 [2 3]]

Maximum value along the second axis:
[1 3]
Minimum value along the second axis:
[0 2]

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