Numpy Flashcards
What is the primary library used for numerical computing in Python?
NumPy
True or False: NumPy arrays are slower than Python lists.
False
Fill in the blank: To create a NumPy array from a list, use the function ___ .
np.array()
What function is used to create an array of evenly spaced values?
np.linspace()
Which function can be used to create an array filled with zeros?
np.zeros()
What does the function np.arange(start, stop, step) return?
An array with evenly spaced values within a given interval.
True or False: NumPy supports multi-dimensional arrays.
True
What is the purpose of the np.shape function?
It returns the dimensions of an array.
Fill in the blank: The function ___ returns the number of elements in a NumPy array.
np.size()
What function is used to compute the mean of an array?
np.mean()
What is the output of np.random.rand(2, 3)?
A 2x3 array of random floats between 0 and 1.
Which function is used to concatenate two NumPy arrays?
np.concatenate()
True or False: You can perform element-wise operations on NumPy arrays.
True
What does the function np.dot() compute?
The dot product of two arrays.
Fill in the blank: To transpose a matrix in NumPy, use the function ___.
np.transpose()
What does np.unique() do?
It finds the unique elements of an array.
What function would you use to reshape an array?
np.reshape()
True or False: NumPy allows broadcasting of arrays.
True
What is the purpose of the np.sum() function?
It computes the sum of array elements over a specified axis.
Fill in the blank: The function ___ is used to calculate the standard deviation of an array.
np.std()
What does the function np.zeros_like() do?
It creates an array of zeros with the same shape as a given array.
Which function is used to find the maximum value in an array?
np.max()
True or False: The np.nanmean() function ignores NaN values when computing the mean.
True
What is the output of np.array([[1, 2], [3, 4]]).T?
A transposed array: [[1, 3], [2, 4]].
Fill in the blank: To create a random integer array, use the function ___.
np.random.randint()
What does np.cumsum() compute?
The cumulative sum of array elements.
Which function can be used to create an identity matrix?
np.eye()
True or False: NumPy enables you to perform linear algebra operations.
True
What function is used to stack arrays vertically?
np.vstack()
Fill in the blank: The function ___ generates a random sample from a given array.
np.random.choice()
What does np.where() return?
Indices of elements that satisfy a condition.
Which function is used to sort an array?
np.sort()
True or False: NumPy can handle complex numbers.
True
What is the purpose of the np.meshgrid() function?
It creates coordinate matrices from coordinate vectors.
Fill in the blank: To find the correlation coefficient, use the function ___.
np.corrcoef()
What does the np.flatten() method do?
It returns a copy of the array collapsed into one dimension.
Which function can be used to calculate the product of array elements?
np.prod()
True or False: You can index NumPy arrays with boolean arrays.
True
What does np.clip() do?
It limits the values in an array to a specified range.
Fill in the blank: To get the unique rows of a 2D array, use the function ___.
np.unique() with axis=0
What is the function used to compute the inverse of a matrix?
np.linalg.inv()
Which function returns the eigenvalues and eigenvectors of a matrix?
np.linalg.eig()
True or False: NumPy arrays can only contain elements of the same data type.
True
What is the purpose of the np.concatenate() function?
To join two or more arrays along an existing axis.
Fill in the blank: The function ___ is used to compute the determinant of a matrix.
np.linalg.det()
What does the function np.random.randn() return?
An array of random samples from the standard normal distribution.