NEW
Font size
WorksheetsPython Quiz 1.6
Total questions: 12
Worksheet time: 6mins
Which of the following is full form of NumPy?
Number Python
Numeric Python
Numerical Python
None of these
Which of the function is a function to create a numpy array?
empty()
array()
ones()
All the above
What is the output of the below code?
np.arange(2,8)
array([2, 3, 4, 5, 6, 7])
array([3, 4, 5, 6, 7])
array([2, 3, 4, 5, 6, 7, 8])
array([3, 4, 5, 6, 7, 8])
Find the output of the below code.
a = np.array([[[1,2,3],[4,5,6]]])
print(a.ndim)
1
(1,3)
3
(3,1)
Find the output of the below code.
a = np.array([[1,2,3],[4,5,6]])
print(a[1,2])
6
5
2
TypeError
What is the output of the below code?
print(np.linspace(1,5,5))
array([1. , 2.33333333, 3.66666667, 5. ])
array([1., 2., 3., 4., 5.])
array([1. , 1.8, 2.6, 3.4, 4.2, 5. ])
None of the above
Which of the following is code gives an error?
a = np.array([(1,2,3),(4,5,6)]) a[(0,1)]
a = np.array([(1,2,3),(4,5,6)]) a.reshape(2,4)
a = np.array([(1,2,3),(4,5,6)]) a[np.arange(1), :]
All the above
What is the output of the below code?
print(np.zeros(5).dtype)
int8
int16
uint8
float64
Which of the following is not true about the identity matrix?
It is a square matrix
It contains 1s in all the diagonals
We can create an identity matrix using the identity() function
None of the above
What is the output of the below code?
np.array([[1,2,3],[4,5,6]]).ravel()
array([1, 2, 3, 4, 5, 6])
array([4, 5, 6, 1, 2, 3])
array((1, 2, 3, 4, 5, 6))
SyntaxError
import numpy as np
arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
print(arr.shape)
2,4
(2,4)
(4,4)
4,4
import numpy as np
arr1 = np.array([1, 2, 3])
arr2 = np.array([4, 5, 6])
arr = np.concatenate((arr1, arr2))
print(arr)
[1 2 3 4 5 6]
[1 2 3 4 5]
(1 2 3 4 5 6)
[1, 2, 3, 4, 5, 6]
