NumPy: Find the maximum and minimum value of a given flattened array
NumPy Statistics: Exercise-1 with Solution
Write a Python program to find the maximum and minimum value of a given flattened array.
import numpy as np a = np.arange(4).reshape((2,2)) print("Original flattened array:") print(a) print("Maximum value of the above flattened array:") print(np.amax(a)) print("Minimum value of the above flattened array:") print(np.amin(a))
Original flattened array: [[0 1] [2 3]] Maximum value of the above flattened array: 3 Minimum value of the above flattened array: 0
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
You can chain comparison operators in Python as following: n = 10 result = 1 < n < 20
distance = 200 checker = 100 < distance < 350 print(checker)
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework