Define NumPy.
A fundamental package for scientific computing in Python, providing support for arrays and matrices.
What does np.array() do?
It creates a NumPy array from a list or tuple.
True or false: NumPy arrays can only hold one data type.
TRUE
NumPy arrays are homogeneous, meaning all elements must be of the same type.
Fill in the blank: ndarray stands for _______.
N-dimensional array
What is the purpose of np.zeros()?
To create an array filled with zeros of a specified shape.
Define broadcasting in NumPy.
A method that allows NumPy to perform arithmetic operations on arrays of different shapes.
What does np.shape() return?
The dimensions of a NumPy array as a tuple.
True or false: NumPy supports complex numbers.
TRUE
NumPy can handle complex numbers using the ‘complex’ data type.
What is the result of np.arange(5)?
An array containing values [0, 1, 2, 3, 4].
Fill in the blank: np.reshape() changes the shape of an array without _______.
Changing its data
What does np.mean() calculate?
The average of the elements in an array.
Define slicing in NumPy.
Extracting a portion of an array using a range of indices.
What error occurs with incompatible shapes in operations?
ValueError: shapes are not aligned.
True or false: NumPy can perform element-wise operations.
TRUE
Operations like addition and multiplication are applied element-wise.
What does np.transpose() do?
It reverses the axes of an array, effectively transposing it.
Fill in the blank: np.concatenate() joins arrays along a _______.
specified axis
What is the output of np.eye(3)?
A 3x3 identity matrix.
Define dtype in NumPy.
Data type of the elements in a NumPy array.
What does np.unique() return?
The unique elements of an array.
True or false: NumPy arrays can be resized.
TRUE
Use the method ‘resize()’ to change the size of an array.
What is the purpose of np.random.rand()?
To generate an array of random numbers between 0 and 1.
Fill in the blank: np.dot() performs _______ product of two arrays.
dot
What does np.std() calculate?
The standard deviation of the elements in an array.
Define masking in NumPy.
Creating a boolean array to filter elements based on conditions.