Numpy Flashcards
(62 cards)
What is NumPy?
NumPy is a fundamental package for scientific computing in Python, providing support for arrays, matrices, and a collection of mathematical functions.
True or False: NumPy arrays can hold elements of different data types.
False
What is the main purpose of the NumPy library?
The main purpose of NumPy is to provide efficient operations on large arrays and matrices along with a collection of mathematical functions to operate on these arrays.
Fill in the blank: The primary data structure in NumPy is the __________.
ndarray
Which function is used to create a NumPy array from a Python list?
np.array()
What does the function np.arange() do?
np.arange() creates an array with evenly spaced values within a given interval.
True or False: NumPy supports multidimensional arrays.
True
What method would you use to find the shape of a NumPy array?
Use the .shape attribute.
Multiple Choice: Which of the following is NOT a valid way to create a NumPy array? (a) np.array([1, 2, 3]) (b) np.zeros(3) (c) np.create_array([1, 2, 3])
c
What does the function np.zeros() return?
np.zeros() returns a new array of given shape and type, filled with zeros.
Fill in the blank: The function np.linspace(start, stop, num) generates __________ evenly spaced samples.
num
What is the purpose of the np.reshape() function?
np.reshape() changes the shape of an existing array without changing its data.
True or False: NumPy provides built-in functions for performing linear algebra operations.
True
What is the difference between a list and a NumPy array?
NumPy arrays are more efficient for numerical operations and support element-wise operations, while lists can hold different data types.
Which function is used to compute the mean of a NumPy array?
np.mean()
Multiple Choice: Which of the following functions can be used to concatenate two NumPy arrays? (a) np.concat() (b) np.append() (c) np.concatenate()
c
What does the function np.transpose() do?
np.transpose() permutes the dimensions of the array, effectively flipping it over its diagonal.
Fill in the blank: To sort a NumPy array in place, you can use the method __________.
sort()
What is broadcasting in NumPy?
Broadcasting is a mechanism that allows NumPy to perform arithmetic operations on arrays of different shapes.
True or False: NumPy can handle missing data in arrays.
True
What does the function np.unique() do?
np.unique() returns the sorted unique elements of an array.
What is the purpose of the np.random module?
The np.random module is used to generate random numbers and perform random sampling.
Multiple Choice: Which of the following is a common use case for NumPy? (a) Web development (b) Data analysis (c) Text processing
b
What is a masked array in NumPy?
A masked array is an array that may have missing or invalid entries, with a mask that indicates which entries are valid.