NumPy Interview Prep
5 min read Quiz at the end
Key NumPy interview topics: ndarray vs list, broadcasting, view vs copy, vectorisation, dtype.
NumPy Interview Topics
- ndarray vs list — ndarray is typed, contiguous memory, supports vectorised ops; lists are general Python objects
- Broadcasting — allows operations between different-shaped arrays by expanding size-1 dimensions
- View vs copy — slices return views (same memory); .copy() creates independent copy
- Vectorisation — replace Python loops with NumPy operations for 10-100x speedup
- axis parameter — axis=0 operates along rows (across rows); axis=1 operates along columns
- dtype — all elements have same type; choose smallest dtype that fits (int8, float32)
- reshape vs resize — reshape returns view with new shape; resize modifies array in-place
- np.where — conditional element selection: np.where(condition, x, y)