10 Most Important Python NumPy MCQs and Answers

In this article, we are going to see 10 Most Important Python NumPy MCQs and Answers which will going to help you in cracking the interview.

Q.1. What is NumPy?
a) A Python package for scientific computing.
b) A Python package for web development.
c) A Python package for database management.
d) A Python package for machine learning.

Answer: a) A Python package for scientific computing.

Q.2. Which of the following is true about NumPy arrays?
a) They can only contain elements of the same data type.
b) They can contain elements of different data types.
c) They can only be one-dimensional.
d) They can only be two-dimensional.

Answer: a) They can only contain elements of the same data type.

Q.3. How do you create a NumPy array?
a) numpy.array([1, 2, 3])
b) numpy.ndarray([1, 2, 3])
c) numpy.array(1, 2, 3)
d) numpy.array(1)

Answer: a) numpy.array([1, 2, 3])

Q.4. What is the output of the following code?

import numpy as np 
arr = np.array([1, 2, 3]) 
print(arr.ndim)

a) 0
b) 1
c) 2
d) 3

Answer: b) 1

Q.5. How do you access the elements of a NumPy array?
a) By using their indices.
b) By using their values.
c) By using their data types.
d) By using their shapes.

Answer: a) By using their indices.

Q.6. What is the output of the following code?

import numpy as np 
arr = np.array([1, 2, 3]) 
print(arr[0])

a) 1
b) 2
c) 3
d) Error

Answer: a) 1

Q.7. What is the output of the following code?

import numpy as np 
arr = np.array([[1, 2, 3], [4, 5, 6]]) 
print(arr.shape)

a) (2, 3)
b) (3, 2)
c) (6,)
d) (2,)

Answer: a) (2, 3)

Q.8. How do you add two NumPy arrays element-wise?
a) arr1 + arr2
b) numpy.add(arr1, arr2)
c) numpy.concatenate((arr1, arr2))
d) numpy.insert(arr1, arr2)

Answer: a) arr1 + arr2

Q.9. How do you transpose a NumPy array?
a) arr.transpose()
b) numpy.transpose(arr)
c) arr.T
d) numpy.T(arr)

Answer: c) arr.T

Q.10. What is the output of the following code?

import numpy as np 
arr = np.array([1, 2, 3]) 
print(np.sum(arr))

a) 1
b) 2
c) 3
d) 6

Answer: d) 6

55 most important Python Numpy mcq questions and answers – Python GDB

Leave a Comment