Python Programming - Arrays

Exercise : Arrays - General Questions
  • Arrays - General Questions
71.
What does the NumPy function numpy.random.randint(1, 100, size=(3, 3)) do?
Generates a random integer between 1 and 100.
Creates a 3x3 array with random integers between 1 and 100.
Reshapes an existing array to have dimensions 3x3.
Computes the mean of random integers between 1 and 100.
Answer: Option
Explanation:
The numpy.random.randint() function creates a random integer array of the specified size.

72.
How can you find the maximum value along a specific axis in a NumPy array arr?
np.max(arr)
arr.maximum(axis=0)
np.maximum(arr, axis=0)
np.max(arr, axis=0)
Answer: Option
Explanation:
The np.max() function can be used with the axis parameter to find the maximum value along a specific axis.

73.
Given a NumPy array arr = np.array([[1, 2, 3], [4, 5, 6]]), how can you access the element 5?
arr[1, 2]
arr[1, 1]
arr[0, 2]
arr[1, 0]
Answer: Option
Explanation:
The indexing starts from 0, so arr[1, 2] refers to the element in the second row and second column.

74.
What is the purpose of the NumPy function numpy.flip(arr, axis=1)?
Flips the array vertically.
Flips the array horizontally.
Flips the array along both axes.
Transposes the array.
Answer: Option
Explanation:
The numpy.flip() function flips the array horizontally along the specified axis.

75.
How can you find the index of the minimum value in a NumPy array arr?
np.min_index(arr)
np.argmin(arr)
arr.find_min_index()
np.minimum_index(arr)
Answer: Option
Explanation:
The np.argmin() function returns the index of the minimum value in the array.