﻿ NumPy: Get the minimum and maximum value of a given array along the second axis - w3resource # NumPy: Get the minimum and maximum value of a given array along the second axis

## NumPy Statistics: Exercise-2 with Solution

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

Sample Solution:-

Python Code:

``````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]
```

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

﻿

## Python: Tips of the Day

Chain Operators

You can chain comparison operators in Python as following: n = 10 result = 1 < n < 20

```distance = 200
checker = 100 < distance < 350

print(checker)
```

Output:

`True`