Numpy Flashcards

1
Q

What is the primary library used for numerical computing in Python?

A

NumPy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: NumPy arrays are slower than Python lists.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fill in the blank: To create a NumPy array from a list, use the function ___ .

A

np.array()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What function is used to create an array of evenly spaced values?

A

np.linspace()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which function can be used to create an array filled with zeros?

A

np.zeros()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the function np.arange(start, stop, step) return?

A

An array with evenly spaced values within a given interval.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or False: NumPy supports multi-dimensional arrays.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the np.shape function?

A

It returns the dimensions of an array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Fill in the blank: The function ___ returns the number of elements in a NumPy array.

A

np.size()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What function is used to compute the mean of an array?

A

np.mean()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the output of np.random.rand(2, 3)?

A

A 2x3 array of random floats between 0 and 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which function is used to concatenate two NumPy arrays?

A

np.concatenate()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or False: You can perform element-wise operations on NumPy arrays.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the function np.dot() compute?

A

The dot product of two arrays.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Fill in the blank: To transpose a matrix in NumPy, use the function ___.

A

np.transpose()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does np.unique() do?

A

It finds the unique elements of an array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What function would you use to reshape an array?

A

np.reshape()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

True or False: NumPy allows broadcasting of arrays.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the purpose of the np.sum() function?

A

It computes the sum of array elements over a specified axis.

20
Q

Fill in the blank: The function ___ is used to calculate the standard deviation of an array.

21
Q

What does the function np.zeros_like() do?

A

It creates an array of zeros with the same shape as a given array.

22
Q

Which function is used to find the maximum value in an array?

23
Q

True or False: The np.nanmean() function ignores NaN values when computing the mean.

24
Q

What is the output of np.array([[1, 2], [3, 4]]).T?

A

A transposed array: [[1, 3], [2, 4]].

25
Q

Fill in the blank: To create a random integer array, use the function ___.

A

np.random.randint()

26
Q

What does np.cumsum() compute?

A

The cumulative sum of array elements.

27
Q

Which function can be used to create an identity matrix?

28
Q

True or False: NumPy enables you to perform linear algebra operations.

29
Q

What function is used to stack arrays vertically?

A

np.vstack()

30
Q

Fill in the blank: The function ___ generates a random sample from a given array.

A

np.random.choice()

31
Q

What does np.where() return?

A

Indices of elements that satisfy a condition.

32
Q

Which function is used to sort an array?

33
Q

True or False: NumPy can handle complex numbers.

34
Q

What is the purpose of the np.meshgrid() function?

A

It creates coordinate matrices from coordinate vectors.

35
Q

Fill in the blank: To find the correlation coefficient, use the function ___.

A

np.corrcoef()

36
Q

What does the np.flatten() method do?

A

It returns a copy of the array collapsed into one dimension.

37
Q

Which function can be used to calculate the product of array elements?

38
Q

True or False: You can index NumPy arrays with boolean arrays.

39
Q

What does np.clip() do?

A

It limits the values in an array to a specified range.

40
Q

Fill in the blank: To get the unique rows of a 2D array, use the function ___.

A

np.unique() with axis=0

41
Q

What is the function used to compute the inverse of a matrix?

A

np.linalg.inv()

42
Q

Which function returns the eigenvalues and eigenvectors of a matrix?

A

np.linalg.eig()

43
Q

True or False: NumPy arrays can only contain elements of the same data type.

44
Q

What is the purpose of the np.concatenate() function?

A

To join two or more arrays along an existing axis.

45
Q

Fill in the blank: The function ___ is used to compute the determinant of a matrix.

A

np.linalg.det()

46
Q

What does the function np.random.randn() return?

A

An array of random samples from the standard normal distribution.