Python NumPy MCQ Questions And Answers
This section focuses on "Python NumPy" for Data Science. These Python NumPy Multiple Choice Questions (MCQ) should be practiced to improve the Data Science skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. NumPY stands for?
A. Numbering Python
B. Number In Python
C. Numerical Python
D. None Of the above
View Answer
Ans : C
Explanation: NumPy, which stands for Numerical Python, is a library consisting of multidimensional array objects
2. Numpy developed by?
A. Guido van Rossum
B. Travis Oliphant
C. Wes McKinney
D. Jim Hugunin
View Answer
Ans : B
Explanation: Numpy developed by Travis Oliphant.
3. NumPy is often used along with packages like?
A. Node.js
B. Matplotlib
C. SciPy
D. Both B and C
View Answer
Ans : D
Explanation: NumPy is often used along with packages like SciPy (Scientific Python) and Matplotlib (plotting library)
4. 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
View Answer
Ans : D
Explanation: Using Numpy, a developer can perform all operations.
5. The most important object defined in NumPy is an N-dimensional array type called?
A. ndarray
B. narray
C. nd_array
D. darray
View Answer
Ans : A
Explanation: The most important object defined in NumPy is an N-dimensional array type called ndarray.
6. 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)
View Answer
Ans : B
Explanation: It creates an ndarray from any object exposing array interface, or from any method that returns an array : numpy.array(object, dtype = None, copy = True, order = None, subok = False, ndmin = 0).
7. What will be output for the following code?
import numpy as np
a = np.array([1,2,3])
print a
A. [[1, 2, 3]]
B. [1]
C. [1, 2, 3]
D. Error
View Answer
Ans : C
Explanation: The output is as follows : [1, 2, 3]
8. What will be output for the following code?
import numpy as np
a = np.array([1, 2, 3,4,5], ndmin = 2)
print a
A. [[1, 2, 3, 4, 5]]
B. [1, 2, 3, 4, 5]
C. Error
D. Null
View Answer
Ans : A
Explanation: The output is as follows : [[1, 2, 3, 4, 5]]
9. What will be output for the following code?
import numpy as np
a = np.array([1, 2, 3], dtype = complex)
print a
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]
View Answer
Ans : D
Explanation: The output is as follows : [ 1.+0.j, 2.+0.j, 3.+0.j]
10. 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)
View Answer
Ans : B
Explanation: A dtype object is constructed using the following syntax : numpy.dtype(object, align, copy)
11. 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
View Answer
Ans : A
Explanation: ndarray is also known as the "alias array".
12. 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
View Answer
Ans : B
Explanation: column_stack is equivalent to vstack only for 1D arrays.
13. 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
View Answer
Ans : C
Explanation: If a dimension is given as -1 in a reshaping operation, the other dimensions are automatically calculated.
14. 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.
View Answer
Ans : D
Explanation: The array object returned by __array_prepare__ is passed to the ufunc for computation is true
15. 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)
View Answer
Ans : C
Explanation: Adjusting the size of the buffer may therefore alter the speed at which ufunc calculations of various sorts are completed.
16. Which of the following set the floating-point error callback function or log object?
A. settercall
B. setterstack
C. setter
D. callstack
View Answer
Ans : A
Explanation: setter sets how floating-point errors are handled.
17. What will be output for the following code?
import numpy as np
dt = dt = np.dtype('i4')
print dt
A. int32
B. int64
C. int128
D. int16
View Answer
Ans : A
Explanation: The output is as follows : int32
18. 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']
A. [[10 20 30]]
B. [10 20 30]
C. [10]
D. Error
View Answer
Ans : B
Explanation: The output is as follows : [10 20 30]
19. 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
View Answer
Ans : B
Explanation: "M" : datetime
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)
View Answer
Ans : D
Explanation: uint32 : Unsigned integer (0 to 4294967295)
Discussion