Numpy MCQs with answers Page - 7

Here, you will find a collection of MCQ questions on Numpy. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833K Points
Coach

Q. Which NumPy function converts a 1D array into a 2D column vector?

  • (A) reshape(-1, 1)
  • (B) flatten()
  • (C) ravel()
  • (D) expand_dims()

A

Admin • 833K Points
Coach

Q. How do you select all rows of a 2D NumPy array where column 0 is greater than 5?

  • (A) arr[arr[:,0]>5]
  • (B) arr[0]>5
  • (C) arr[arr>5, 0]
  • (D) arr[arr>5][:,0]

A

Admin • 833K Points
Coach

Q. What does np.isnan(np.nan) return?

  • (A) True
  • (B) False
  • (C) None
  • (D) Error

A

Admin • 833K Points
Coach

Q. How to get the index of the maximum value in a NumPy array?

  • (A) np.argmax()
  • (B) np.maxindex()
  • (C) np.indexmax()
  • (D) np.topindex()

A

Admin • 833K Points
Coach

Q. Which function calculates the variance of NumPy array elements?

  • (A) np.variance()
  • (B) np.var()
  • (C) np.std()
  • (D) np.mean()

A

Admin • 833K Points
Coach

Q. Which of the following is NOT a valid NumPy data type?

  • (A) int32
  • (B) float64
  • (C) str64
  • (D) complex128

A

Admin • 833K Points
Coach

Q. How to compute the cross product of two vectors?

  • (A) np.cross()
  • (B) np.dot()
  • (C) np.product()
  • (D) np.multiply()

A

Admin • 833K Points
Coach

Q. Which function returns the matrix inverse in NumPy?

  • (A) np.linalg.inv()
  • (B) np.inverse()
  • (C) np.matinv()
  • (D) np.inverse_mat()

A

Admin • 833K Points
Coach

Q. What does np.allclose(a, b) check?

  • (A) Whether all elements are exactly equal
  • (B) Whether all elements are numerically close within a tolerance
  • (C) Whether arrays a and b have the same shape
  • (D) Whether arrays contain all non-zero values

A

Admin • 833K Points
Coach

Q. Which of these will raise an error when passed to np.array()?

  • (A) [[1,2],[3,4]]
  • (B) [1,2,3]
  • (C) [[1,2],[3]]
  • (D) np.arange(5)