## Python Numpy mcq questions and answers

55 most important Python Numpy mcq questions and answers are given below. These **Numpy multiple choice questions** include both theory and **coding questions** based on Numpy. We are also planning to add Numpy mcq questions and answers pdf download link. NumPy is a library for the **Python programming language**, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. We have added **mcq on Pandas** and **Python mcq questions** and **PySpark**.

**Q.1. NumPY stands for?**

A : Numbering Python

B : Number In Python

C : Numerical Python

D : None Of the above

**C : Numerical Python.**

**Q.2. NumPy is often used along with packages like?**

A : Node.js

B : Matplotlib

C : SciPy

D : Both B and C

**NumPy is often used along with Matplotlib and SciPy packages.**

**Q.3. The most important object defined in NumPy is an N-dimensional array type called?**

A : ndarray

B : narray

C : nd_array

D : darray

**A: ndarray. The most important object defined in NumPy is an N-dimensional array type called ndarray.**

**4. What will be output for the following code?**

**import numpy as npa = np.array([1,2,3])print aQ.**

A : [[1, 2, 3]]

B : [1]

C : [1, 2, 3]

D : Error

**C: [1, 2, 3].**

Explanation:

The code creates a one-dimensional NumPy array using the np.array() function with the input [1,2,3].

Then, the print statement is used to output the value of the array “a”.

Since “a” is a one-dimensional array, the output will be [1, 2, 3].

**5. What will be output for the following code?**

**import numpy as npa = np.array([1, 2, 3], dtype = complex)print aQ.**

A : [[ 1.+0.j, 2.+0.j, 3.+0.j]]

B : [ 1.+0.j]

C : Error

D : [ 1.+0.j, 2.+0.j, 3.+0.j]

[[ 1.+0.j, 2.+0.j, 3.+0.j]]

**D: [ 1.+0.j, 2.+0.j, 3.+0.j].**

Explanation:

The code creates a one-dimensional NumPy array using the np.array() function with the input [1, 2, 3] and data type complex.

Then, the print statement is used to output the value of the array “a”.

Since “a” is a one-dimensional array of complex numbers, the output will be [ 1.+0.j, 2.+0.j, 3.+0.j], where the “j” indicates that the numbers are complex.

**Q.6. Which of the following statement is false?**

A : ndarray is also known as the axis array.

B : ndarray.dataitemSize is the buffer containing the actual elements of the array.

C : NumPy main object is the homogeneous multidimensional array

D : In Numpy, dimensions are called axes

**ndarray is also known as the axis array.**

**Q.7. If a dimension is given as ____ in a reshaping operation, the other dimensions are automatically calculated.**

A : Zero

B : One

C : Negative one

D : Infinite

**C: Negative one.**

**Q.8. Which of the following sets the size of the buffer used in ufuncs?**

A : bufsize(size)

B : setsize(size)

C : setbufsize(size)

D : size(size)

**C: setbufsize(size).**

**9. What will be output for the following code?**

**import numpy as npdt = dt = np.dtype(‘i4’)print dtQ.**

A : int32

B : int64

C : int128

D : int16

**A: int32.**

**Q.10. Each built-in data type has a character code that uniquely identifies it.What is meaning of code “M”?**

A : timedelta

B : datetime

C : objects

D : Unicode

**B: datetime.**

**Q.11. Numpy developed by?**

A : Guido van Rosum

B : Travis Oliphant

C : Wes McKinney

D : Jim Hugunin

**B : Travis Oliphant**

**Q.12. Which of the following Numpy operation are correct?**

A : Mathematical and logical operations on arrays.

B : Fourier transforms and routines for shape manipulation.

C : Operations related to linear algebra.

D : All of the above

**A: All of the above are correct. Numpy provides a wide range of mathematical, logical, and linear algebra operations, as well as Fourier transforms and routines for shape manipulation.**

**Q.13. The basic ndarray is created using?**

A : numpy.array(object, dtype = None, copy = True, subok = False, ndmin = 0)

B : numpy.array(object, dtype = None, copy = True, order = None, subok = False, ndmin = 0)

C : numpy_array(object, dtype = None, copy = True, order = None, subok = False, ndmin = 0)

D : numpy.array(object, dtype = None, copy = True, order = None, ndmin = 0)

**numpy.array(object, dtype = None, copy = True, order = None, subok = False, ndmin = 0)**

**14. What will be output for the following code?**

**import numpy as npa = np.array([1, 2, 3,4,5], ndmin = 2)print aQ.**

A : [[1, 2, 3, 4, 5]]

B : [1, 2, 3, 4, 5]

C : Error

D : Null

**A : [[1, 2, 3, 4, 5]]**

**Q.15. What is the syntax for dtype object?**

A : numpy.dtype(object, align, copy, subok)

B : numpy.dtype(object, align, copy)

C : numpy.dtype(object, align, copy, ndmin)

D : numpy_dtype(object, align, copy)

**numpy.dtype(object, align, copy)**

**Q.16. Which of the following function stacks 1D arrays as columns into a 2D array?**

A : row_stack

B : column_stack

C : com_stack

D : All of the above

**B : column_stack**

**Q.17. Which of the following statement is true?**

A : Some ufuncs can take output arguments.

B : Broadcasting is used throughout NumPy to decide how to handle disparately shaped arrays

C : Many of the built-in functions are implemented in compiled C code

D : The array object returned by __array_prepare__ is passed to the ufunc for computation.

**The array object returned by __array_prepare__ is passed to the ufunc for computation.**

**Q.18. Which of the following set the floating-point error callback function or log object?**

A : settercall

B : setterstack

C : setter

D : callstack

**C : setter**

**19. What will be output for the following code?**

**import numpy as npdt = np.dtype([(‘age’,np.int8)])a = np.array([(10,),(20,),(30,)], dtype = dt)print a[‘age’]Q.**

A : [[10 20 30]]

B : [10 20 30]

C : [10]

D : Error

**B : [10 20 30]**

**Q.20. What is the range of uint32 data type?**

A : (-2147483648 to 2147483647)

B : (-32768 to 32767)

C : (0 to 65535)

D : (0 to 4294967295)

**D : (0 to 4294967295)**

## numPY and Pandas mcq questions

**Q.21. What will be printed?**

**import numpy as npa = np.array([1,2,3,5,8])b = np.array([0,3,4,2,1])c = a + bc = c*aprint (c[2])**

A : 7

B : 12

C : 10

D : 21

**D : 21**

**Q.22. What will be output for the following code?**

import numpy as np

ary = np.array([1,2,3,5,8])

ary = ary + 1

print (ary[1])

A : 0

B : 1

C : 2

D : 3

**D : 3**

**Q.23. What will be output for the following code?**

import numpy as np

a = np.array([[1,2,3],[0,1,4]])

print (a.size)

A : 1

B : 5

C : 6

D : 4

**C : 6**

**Q.24. What will be output for the following code?**

import numpy as np

a = np.array([1,2,3,5,8])

print (a.ndim)

A : 0

B : 1

C : 2

D : 3

**B : 1**

**Q.25. What will be output for the following code?**

import numpy as np

a = np.array([[1,2,3],[0,1,4]])

b = np.zeros((2,3), dtype=np.int16)

c = np.ones((2,3), dtype=np.int16)

d = a + b + c

print (d[1,2] )

A : 5

B : 7

C : 3

D : 4

**A : 5**

**Q.26. What is the correct code to install numpy in the linux system containing python3?**

A : pip numpy install python3

B : pip3 install numpy

C : pip install numpy

D : python3 pip3 numpy install

**B : pip3 install numpy**

**Q.27. What is the correct code to install numpy in the windows system containing python3?**

A : pip3 install numpy

B : pip install numpy

C : python3 install numpy

D : none of above

**B : pip install numpy**

**Q.28. fetch numpy as np**np.array(list)

Is it true to import numpy module like this?

A : Yes, true

B : Syntax Error

**A : Yes, true**

**Q.29. import numpy as npnp.array(list)Is it true to import numpy module like this?**

A : Yes, true

B : Not, true

C : Syntax Error

D : All of above

**A : Yes, true**

**Q.30. How to import numpy module?**

A : from numpy import *

B : import numpy

C : import numpy as my_numpy

D : import numpy as np

E : all of above

**D : import numpy as np**

**Q.31. What is zero() function in numpy use to?**

A : make a matrix with first column 0

B : make a matrix with all elements 0

C : make a matrix with diagonal elements 0

D : All of the above

**make a matrix with all elements 0**

**Q.32. What does it do?array.min()**

A : finds the maximum number in numpy array

B : finds the minimum number in numpy array

C : makes operation of minus if x < 100 D : answers B & C

**finds the minimum number in numpy array**

**Q.33. Is the following statement true?numpy array can be converted to the list in python3?**

A : false

B : true

C : can’t say

D : None of the above

**B : true**

**Q.34. Choose the true properties of nd-array as.**

A : fast and flexible container for large datasets in python

B : Homogeneous data i.e. all of the elements must be the same type

C : None of the above

D : Both A & B

**D : Both A & B**

**Q.35. Regarding creating ndarray, choose the build in functions in numpy.**

A : np.array()

B : np.zeros()

C : np.empty()

D : np.arange()

E : All of the above

**E : All of the above**

**Q.36. What are the attributes of numpy array?**

A : shape, dtype, ndim

B : objects, type, list

C : objects, non vectorization

D : Unicode and shape

**A: sum(), any(), np.type() are not all relevant methods for boolean in numpy array.**

**Q.37. Methods for boolean in numpy array.Choose the relevant from the following options.**

A : sum(), any(), np.type()

B : sum(), any(), all(), np.type()

C : objects(), any()

D : sum(), any(), all()

**B: sum(), any(), all(), np.type() are relevant methods for boolean in numpy array.**

**Q.38. What is Fortran order in numpy?**

A : reshaping regarding row major order

B : reshaping regarding column major order

C : converting to 1D array

D : All of the above

reshaping regarding column major order

**Q.39. Correct syntax of the reshape() function in Numpy array python is**

A : array.reshape(shape)

B : reshape(shape,array)

C : reshape(array,shape)

D : reshape(shape)

**A : array.reshape(shape)**

**Q.40. How we can change the shape of the Numpy array in python?**

A : By Shape()

B : By reshape()

C : By ord()

D : By change()

**B : By reshape()**

**Q.41. How we can convert the Numpy array to the list in python?**

A : list(array)

B : list.array

C : array.list

D : None of the above

**A: The correct answer is A, i.e., list(array). To convert a Numpy array to a list in Python, we can use the built-in list() function by passing the Numpy array as an argument.**

**Q.42. How we can find the type of numpy array in python ?**

A : dtype

B : type

C : typei

D : itype

**A: The answer is A: dtype. We can use the dtype attribute of numpy array to find its data type.**

**Q.43. How we install Numpy in the system ?**

A : install numpy

B : pip install python numpy

C : pip install numpy

D : pip install numpy python

**A: The answer is C: pip install numpy. We can use pip, the package installer for Python, to install Numpy in our system.**

**Q.44. It is possible to convert the Numpy array to list in python ?**

A : Yes

B : No

C : Sometimes

D : None of the above

**A: The answer is A: Yes. We can use the tolist() method of numpy array to convert it into a Python list.**

**Q.45. Minimum number of argument to pass in full() function in Numpy array ?**

A : 0

B : 1

C : 2

D : 3

**A: The answer is B: 1. We need to pass at least one argument, which is the shape of the Numpy array, to the full() function.**

**Q..46 Numpy in the Python provides the**

A : Function

B : Lambda function

C : Type casting

D : Array

**A: The answer is D: Array. Numpy is a Python library that provides support for multi-dimensional arrays and matrices, along with a large collection of mathematical functions to operate on these arrays.**

**Q.47. Numpy.array(list), what it does ?**

A : It convert array to list

B : It convert list to array

C : It convert array to array

D : Error

**A: The answer is B: It converts list to array. The numpy.array() function is used to create a new Numpy array from a Python list.**

**Q.48. Shape() function in Numpy array is used to**

A : Find the shape of the array

B : Change the shape of the array

C : Both of the above

D : None of the above

Find the shape of the array

**Q.49. What is the use of the size attribute in Numpy array in python ?**

A : It find the direction

B : It find the number of items

C : It find the shape

D : All of the above

It find the number of items

**Q.50. what is the use of the zeros() function in Numpy array in python ?**

A : To make a Matrix with all element 0

B : To make a Matrix with all diagonal element 0

C : To make a Matrix with first row 0

D : None of the above

To make a Matrix with all element 0

**Q.51. Which of the following argument we need to pass in reshape() function?**

A : Array

B : Shape

C : only array

D : Both array and shape

**B: Shape. In the reshape() function of Numpy, we need to pass the new shape of the array as an argument.**

**Q.52. Which of the following counts the number of elements in Numpy array ?**

A : count()

B : return()

C : shape()

D : size()

**D: size(). The size() function in Numpy returns the number of elements in the array.**

**Q.53. Which of the following find the maximum number in the Numpy array ?**

A : max(array)

B : array.max()

C : array(max)

D : None of the above

**B: array.max(). The max() function in Numpy can be called directly on the array as a method to find the maximum element in the array.**

**Q.54. Which of the following is correct way to import the Numpy module in your program ?**

A : import numpy

B : import numpy as np

C : from numpy import *

D : All of the above

**B: import numpy as np. This is the standard and recommended way of importing the Numpy module in Python. Option A is also valid but it requires the use of the full module name whenever a Numpy function is called. Option C is not recommended as it can lead to namespace pollution.**

**Q.55. Which of the following is not valid to import the numpy module ?**

A : import numpy as np

B : import numpy as n

C : import numpy as p

D : None of the above

**C : import numpy as p is not a valid way to import the numpy module.**

**Q.56. Which of the following is the essential argument to pass in full() function of Numpy array ?**

A : shape

B : value

C : Both of the above

D : None of the above

**A : shape is the essential argument to pass in full() function of Numpy array.**

**Q.57. Which of the following is used to convert the list data type to the Numpy array ?**

A : array(list)

B : array.list

C : Numpy.array(list)

D : None of the above

**A : array(list) is used to convert the list data type to the Numpy array.**

**Q.58. Which of the following keyword is used to access the numpy module in python ?**

A : access

B : import

C : fetch

D : from

**D : from is used to access the numpy module in python. For example: from numpy import ***