Python Programming - Arrays

Exercise : Arrays - General Questions
  • Arrays - General Questions
46.
What is the purpose of the NumPy function numpy.argmax(arr)?
Finds the minimum value in the array.
Returns the index of the maximum value in the array.
Computes the average value of the array.
Reshapes the array to have a specified number of dimensions.
Answer: Option
Explanation:
The numpy.argmax() function returns the index of the maximum value in the array.

47.
What does the NumPy function numpy.eye(3) do?
Creates a 3x3 array with random values.
Generates an identity matrix of size 3x3.
Computes the eigenvalues of a 3x3 matrix.
Reshapes an existing array to have dimensions 3x3.
Answer: Option
Explanation:
The numpy.eye() function generates an identity matrix of the specified size.

48.
How can you find the mean value along a specific axis in a NumPy array arr?
np.mean(arr, axis=1)
np.average(arr, axis=0)
arr.calculate_mean(axis=1)
arr.mean(axis=0)
Answer: Option
Explanation:
The np.mean() function can compute the mean along a specified axis.

49.
Given two NumPy arrays arr1 and arr2, what does np.vstack((arr1, arr2)) do?
Stacks the arrays vertically.
Stacks the arrays horizontally.
Creates a new array by vertically concatenating the arrays.
Creates a new array by horizontally concatenating the arrays.
Answer: Option
Explanation:
The np.vstack() function stacks the arrays vertically.

50.
What is the output of the code np.arange(2, 10, 2)?
[2, 4, 6, 8]
[2, 4, 8]
[2, 6]
[2, 4, 8, 10]
Answer: Option
Explanation:
The code generates an array with values from 2 to 10 (exclusive) with a step of 2.