In this post, we cover all important Questions from the topic "NumPy Basics".

These MCQs will definitely help to pass IT and Computer students in any exam and interview that have NumPy Basics topic.

#### The NumPy Basics chapter covers the following topics:

Introduction to NumPy,ndarray, datatypes, array attributes, array creation

routines, Array From Existing Data, Array From Numerical Ranges, Indexing & Slicing.

After completion of the NumPy Basics unit, Students will be able to  work on NumPy array manipulation to access data and subarrays and to split, reshape, join arrays etc.

# NumPy Basics MCQs

Here are the 65 most important and frequently asked MCQs from the  "NumPy Basics" topic.

1. Numpy developed by?

a) Guido van Rosum

b) Travis Oliphant

c) Wes McKinney

d) Jim Hugunin

Ans. b) Travis Oliphant

2. NumPY stands for?

a) Numbering Python

b) Number In Python

c) Numerical Python

d) None Of the above

Ans. c)Numerical Python

3. What are the attributes of numpy array?

a) shape, dtype, ndim

b) objects, type, list

c) objects, non vectorization

d) Unicode and shape

Ans.a) shape, dtype, ndim

4. 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

Ans.  b)

5. Minimum number of argument to pass in full() function in Numpy array ?

a) 0

b) 1

c) 2

d) 3

Ans. c) 2

6. What will be output for the following code?

import numpy as np

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

print a

Q.

a) [[1, 2, 3]]

b) 

c) [1, 2, 3]

d) Error

Ans. [1, 2, 3]

7. What will be output for the following code?

import numpy as np

dt = dt = np.dtype(‘i4’)

print dt

Q.

a) int32

b) int64

c) int128

d) int16

Ans. a) int32

8. 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

Ans. c) Negative one

9. 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)

Ans. b) numpy.dtype(object, align, copy)

10. What is the use of shape() in numpy?

a) change in shape of array

b) reshaping of array

c) shape of the array

d) all of above

Ans. c)

11. 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

Ans. d)All of the above

12. 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

Ans.a)

13. 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

Ans. a) 5

14. reshape() function in numpy array using python is:

a) reshape(shape)

b) array.reshape(shape)

c) reshape(array, shape)

d) numpy.reshape(array)

Ans.  c)

15. 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)

Ans. b)

16. Which of the following counts the number of elements in Numpy array ?

a) count()

b) return()

c) shape()

d) size()

Ans. d) size()

17. How to convert numpy array to list?

a) array.list()

b) array.list

c) list.array()

d) list(array)

Ans. D

18. 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()

Ans. d) sum(), any(), all()

19. 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

Ans.b)

20. How to import numpy module?

a) from numpy import *

b) import numpy

c) import numpy as my_numpy

d)  all of above

Ans. d)

21. What does size attribute in numpy use to find?

a) shape

b) date & time

c) objects

d) number of items

Ans. D

22. 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

Ans. a) list(array)

23. What will be output for the following code?

import numpy as np

a = np.array([1, 2, 3], dtype = complex)

print a

Q.

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]

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

24. 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

Ans.a)

25. Numpy in the Python provides the

a) Function

b) Lambda function

c) Type casting

d) Array

Ans.d) Array

26. How we can find the type of numpy array in python ?

a) dtype

b) type

c) typei

d) itype

Ans. a) dtype

27. How we install Numpy in the system ?

a) install numpy

b) pip install python numpy

c) pip install numpy

d) pip install numpy python

Ans. c) pip install numpy

28. 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

Ans.b)

29. It is possible to convert the Numpy array to list in python ?

a) Yes

b) No

c) Sometimes

d) None of the above

Ans. a) Yes

30. 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

Ans.  b)

31. Is the following statement true?

numpy array can be converted to the list in python3?

a) Not at all

b) Yes, true

c) Yes, most of the time but not every time

d) Not true because numpy has nothing to do with lists

Ans.  b)

32. 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

Ans. c) Numpy.array(list)

33. 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)

Ans. c)  reshape(array,shape)

34. 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

Ans. a)

35. What will be printed?

import numpy as np

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

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

c = a + b

c = c*a

print (c)

a) 7

b) 12

c) 10

d) 21

Ans.d) 21

36. 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)

a) 0

b) 1

c) 2

d) 3

Ans. d) 3

37. 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

Ans. c) 6

38. 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

Ans. b) 1

39. What does size() do in numpy?

a) counts the number of elements

b) estimates the array of maximum numbers

c) finds shape of array

d) code is wrong

Ans.  a)

40. NumPy is often used along with packages like?

a) Node.js

b) Matplotlib

c) SciPy

d) Both B and C

Ans.  d) Both B and C

41. How to find the type of numpy array?

a) type(array)

b) dtype

c) objects.type(array)

d) numpy(type)

Ans.  b) dtype

42. What is the range of uint32 data type?

a) (-2147483648 to 2147483647)

b) (-32768 to 32767)

c) (0 to 65535)

d) (0 to 4294967295)

Ans. d) (0 to 4294967295)

43. How we can change the shape of the Numpy array in python?

a) By Shape()

b) By reshape()

c) By ord()

d) By change()

Ans. b) By reshape()

44. Which of the following keyword is used to access the numpy module in python ?

a) access

b) import

c) fetch

d) from

Ans. b) import

45. The most important object defined in NumPy is an

N-dimensional array type called?

a) ndarray

b) narray

c) nd_array

d) darray

Ans.  a) ndarray

46. 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)

Ans.  c)

47. 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

Ans. b)

48. 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

Ans.d) None of the above

49. 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

Ans.c) Both of the above

50. 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

Ans.d) Both A & B

51. full() function requires 2 arguments minimum to pass in it.

a) true

b) false

c) none of above

d) full() doesn't belong to numpy

Ans. a) true

52. Choose one of the unique property of numpy.

a) array

b) reshape

c) shape

d) Unicode

Ans.  a) array

53. Choose the correct option to pass arguments to full() function in numpy.

a) only value

b) only shape

c) shape and value

d) none of the above

Ans.  c) shape and value

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

a) Array

b) Shape

c) only array

d) Both array and shape

Ans.d)

55. 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

Ans.b) array.max()

56. import numpy as np

np.array(list)

Is it true to import numpy module like this?

a) Yes, true

b) Not, true

c) Syntax Error

d) All of above

Ans.a) Yes, true

57. 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

Ans.  b)

58. Choose the correct statement to load numpy file in python.

c) np.save(filename.npy, array)

d) all of the above

59. What will be output for the following code?

import numpy as np

dt = 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) 

d) Error

Ans. b)[10 20 30]

60. what is the output of x here?

import numpy as np

x = np.array(list)

a) conversion of list to array

b) conversion of array to list

c) conversion of list to list

d) All of above

Ans.  a)

61. 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

Ans. b) datetime

62. Regarding creating ndarray, choose the build in functions in numpy.

a) np.array()

b) np.zeros()

c) np.empty()

d) All of the above

Ans.d)  All of the above

63. 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

Ans.b) 1

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

a) settercall

b) setterstack

c) setter

d) callstack

Ans. a) settercall

65. What will be output for the following code?

import numpy as np

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

print a

Q.

a) [[1, 2, 3, 4, 5]]

b) [1, 2, 3, 4, 5]

c) Error

d) Null

Ans. a) [[1, 2, 3, 4, 5]]