Python Quiz on NumPy Sorting Array
There are 20 questions based on NumPy Sorting Array .
Sign in to Google to save your progress. Learn more
Q1.  What is the output of the following code?
import numpy as np
arr = np.array([3, 1, 2])
print(np.sort(arr))
*
4 points
Q2.  What will be printed?
arr = np.array([4, 2, 9])
arr.sort()
print(arr)
*
4 points
Q3. What is the output of this code?
arr = np.array([[3, 2, 1], [6, 5, 4]])
print(np.sort(arr))
*
4 points
Q4.  Which axis will sort the columns of a 2D array?
arr = np.array([[3, 2], [1, 4]])
print(np.sort(arr, axis=0))
*
4 points
Q5.  What does np.argsort() return?
arr = np.array([30, 10, 20])
print(np.argsort(arr))
  
*
4 points
Q6.  What is the effect of [::-1] on a sorted array?
arr = np.array([4, 1, 3])
print(np.sort(arr)[::-1])
  
*
4 points
Q7.  What does this return?
arr = np.array([[7, 8], [1, 3]])
print(np.sort(arr, axis=None))
*
4 points
Q8.  How do you sort a NumPy array in descending order?
arr = np.array([5, 2, 9])
print(np.sort(arr)[::-1])
*
4 points
Q9.  What is the result of sorting along axis=1?
arr = np.array([[3, 2, 1], [6, 5, 4]])
print(np.sort(arr, axis=1))
  
*
4 points
Q10. What does this output?
arr = np.array(['banana', 'apple', 'cherry'])
print(np.sort(arr))
*
4 points
Q11.  Which method is used to return the indices that would sort an array?
arr = np.array([3, 1, 2])
print(np.argsort(arr))
*
4 points
Q12.  What does this return?
arr = np.array([[3, 2], [1, 4]])
print(np.sort(arr, axis=1))
*
4 points
Q13.  Can NumPy sort strings?
arr = np.array(['cat', 'dog', 'apple'])
print(np.sort(arr))
*
4 points
Q14.  Sorting a boolean array:
arr = np.array([True, False, True])
print(np.sort(arr))
*
4 points
Q15.  What is the sorted version of this 2D array?
arr = np.array([[5, 2], [3, 8]])
print(np.sort(arr, axis=0))
*
4 points
Q16.  What is the output of this code?
import numpy as np
arr = np.array([[9, 3], [1, 5]])
print(np.sort(arr, axis=1))
*
4 points
Q17.  What is the output of argsort() here?
arr = np.array([40, 10, 20])
print(np.argsort(arr))
  
*
4 points
Q18.  What will be printed?
arr = np.array([True, False, True])
print(np.sort(arr)[::-1])
*
4 points
Q19. What does this output?
arr = np.array([[5, 3], [2, 4]])
print(np.argsort(arr, axis=0))
*
4 points
Q20.  What is the output?
arr = np.array([[4, 1], [2, 3]])
print(np.argsort(arr, axis=1))
*
4 points
Submit
Clear form
This content is neither created nor endorsed by Google.