NumPy Quiz
Check what you learned in the NumPy tutorial with this short quiz.
How the Quiz Works
There are eight questions. Pick an answer to see if it is right and read the short explanation. Assume every question starts with import numpy as np.
| Questions | Topics |
|---|---|
| 1 to 3 | Creating arrays, dimensions and shape |
| 4 to 5 | Indexing, slicing and maths |
| 6 to 8 | Statistics, axis and filtering |
Questions
Exercise
1. What does np.zeros((2, 3)).shape return?
Exercise
2. What does np.arange(0, 10, 3) give?
Exercise
3. Which call turns a 1-D array of 12 numbers into 3 rows and 4 columns?
Exercise
4. m = np.array([[1, 2, 3], [4, 5, 6]]). What is m[1, 2]?
Exercise
5. What does np.array([1, 2, 3]) * np.array([2, 2, 2]) return?
Exercise
6. Which function gives the INDEX of the largest value?
Exercise
7. For a marks table with students as rows, how do you get the average of each subject (column)?
Exercise
8. Which code keeps values from arr that are between 10 and 20?
What Next?
Done? Continue with Pandas, which uses NumPy under the hood to work with tables of data.
