Predict the ufunc Output
Intermediate · Predict the output · from NumPy Operations: Element-wise Math, Aggregations, and ufuncs
From the lesson: NumPy Operations: Element-wise Math, Aggregations, and ufuncs
You know how to create NumPy arrays. Now it's time to actually do things with them. The real power of NumPy is that you can perform math on entire arrays at once - no loops required.
Read the lessonWhat does the following code print?
import numpy as np
a = np.array([4, 9, 16, 25])
b = np.sqrt(a)
print(b)
print(np.sum(b))import numpy as np
a = np.array([4, 9, 16, 25])
b = np.sqrt(a)
print(b)
print(np.sum(b))
More NumPy Operations exercises
- Apply Sales TaxIntermediate
- Student Grade SummaryIntermediate
- Per-Student AveragesIntermediate
- Filter the Hot DaysIntermediate
- Rank the Top 3 ScoresIntermediate
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz