Numpy Interview Questions
Numpy Interview Questions
1. What is NumPy?
NumPy (Numerical Python) is a powerful library for numerical computing in Python. It provides
support for large, multi-dimensional arrays and matrices, along with a collection of mathematical
functions to operate on these arrays efficiently.
NumPy arrays are more efficient than Python lists because they consume less memory and provide
faster execution for numerical computations. Unlike lists, NumPy arrays support element-wise
operations and broadcasting, making vectorized operations possible.
You can create a NumPy array using the `numpy.array()` function by passing a list or tuple.
Example:
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
Broadcasting is a feature in NumPy that allows arrays with different shapes to be operated on
together. NumPy automatically expands smaller arrays to match the shape of larger ones, making
element-wise operations efficient.