Solution Review: Using Numpy and Scipy
This lesson provides the solutions to the previous challenges.
Numpy #
Press + to interact
import numpy as np # importing numpy moduledef perform_calculations(array):# returning max, std, sum, and dot productreturn np.max(array), np.std(array), np.sum(array), np.dot(array, array)# calling the function and printing resultprint(perform_calculations(np.random.rand(5)))
According to the problem statement, we needed these four values using one numpy
1-D array as an output: max, std, sum, and dot product. In the code above, at line 1 we imported the numpy
...
Access this course and 1400+ top-rated courses and projects.