Python NumPy MCQs
11. 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.
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
View Answer
Ans : D
Explanation: Using Numpy, a developer can perform all operations.
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)
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).
14. 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]]
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)
View Answer
Ans : B
Explanation: A dtype object is constructed using the following syntax : numpy.dtype(object, align, copy)
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
View Answer
Ans : B
Explanation: column_stack is equivalent to vstack only for 1D arrays.
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.
View Answer
Ans : D
Explanation: The array object returned by __array_prepare__ is passed to the ufunc for computation is true
18. 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.
19. 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]
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