Python Programming - Arrays

Exercise : Arrays - General Questions
  • Arrays - General Questions
21.
What is the purpose of the numpy.concatenate() function in NumPy?
Concatenates two Python lists.
Combines two NumPy arrays along a specified axis.
Merges two dictionaries.
Joins two strings.
Answer: Option
Explanation:
The numpy.concatenate() function in NumPy is used to concatenate two arrays along a specified axis.

22.
Which NumPy function is used to find the unique elements of an array?
numpy.unique()
numpy.distinct()
arr.unique()
numpy.find_unique()
Answer: Option
Explanation:
The numpy.unique() function is used to find the unique elements of an array.

23.
What does the function numpy.zeros_like(arr) do in NumPy?
Creates a new array with zeros of the same shape as arr.
Fills the existing array arr with zeros.
Checks if all elements in arr are zero.
Reshapes arr to have all zero elements.
Answer: Option
Explanation:
The numpy.zeros_like() function creates a new array with zeros of the same shape as the input array arr.

24.
How do you stack two NumPy arrays vertically?
np.concatenate((arr1, arr2), axis=0)
np.vstack((arr1, arr2))
np.stack((arr1, arr2), axis=0)
np.append(arr1, arr2, axis=0)
Answer: Option
Explanation:
The np.vstack() function in NumPy is used to stack arrays vertically.

25.
What does the numpy.transpose() function do?
Flips the array vertically.
Swaps the axes of the array.
Rotates the array 90 degrees.
Converts the array to a transposed form.
Answer: Option
Explanation:
The numpy.transpose() function swaps the axes of the array.