Numpy Arrays: Exercises


5. NumPy Array Functions. NumPy provides a variety of functions that can be applied to arrays to perform mathematical operations. Functions like numpy.mean(), numpy.max(), and numpy.min() allow you to compute statistics on arrays.

For example, you can find the mean of a NumPy array like this: mean_value = numpy.mean(array).


# Import the NumPy library import numpy as np # Create a NumPy array of numbers array = np.array([1, 2, 3, 4, 5]) # Calculate the mean of the array mean_value = ___ # Print the mean value print(mean_value) # Import the NumPy library import numpy as np # Create a NumPy array of numbers array = np.array([1, 2, 3, 4, 5]) # Calculate the mean of the array mean_value = np.mean(array) # Print the mean value print(mean_value) test_object("mean_value") success_msg("You have correctly calculated the mean of a NumPy array.")
NumPy provides functions like numpy.mean() for performing operations on arrays.

Previous Exercise Next Exercise