NEW
Font size
WorksheetsNumPy Quiz
Total questions: 21
Worksheet time: 11mins
What is NumPy primarily used for?
Creating GUIs
File handling
Numerical computations
Web development
Game development
What function creates an array with values [0, 1, 2, 3, 4]?
np.arange(5)
np.range(5)
np.linspace(0,5)
np.array(5)
np.series(5)
How can you create an array of all ones with shape (2,3)?
np.ones((2,3))
np.ones[2,3]
np.one((2,3))
np.full((2,3), 1.0)
Both a and d
What will be the output of np.array([1, 2, 3]) * 2?
[1, 2, 3, 1, 2, 3]
[2, 4, 6]
[1, 2, 3, 2]
[1, 4, 9]
Error
What does np.array([1, 2, 3]).ndim return?
1
2
3
0
Error
What will np.arange(1, 10, 2) output?
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 3, 5, 7, 9]
[1, 2, 4, 6, 8]
[2, 4, 6, 8, 10]
Error
What is the output of np.array([[1, 2], [3, 4]]).shape?
(2, 2)
2
(4,)
(2,)
(1, 4)
Which NumPy function creates a sequence of evenly spaced numbers over a specified interval?
arange()
range()
linspace()
series()
spacing()
Which of the following will create a NumPy array?
np.array([1, 2, 3])
np.array(range(3))
np.array((1, 2, 3))
All of the above
Only a and b
What will np.sum(np.array([1,2,3])) return?
6
[6]
3
Error
None
Which of the following is not a NumPy data type?
int32
float64
bool_
dict
complex128
What does np.eye(3) create?
A 3x3 matrix of ones
A 3x3 identity matrix
A 3x3 matrix of zeros
A 3x1 matrix
A diagonal matrix with 3s
What does np.full((2, 2), 7) do?
Creates a 2x2 matrix filled with 7s
Creates a 2-element array
Fills the array with random numbers
Creates a 2x7 matrix
Error
Which attribute returns the number of dimensions of an array?
shape
size
ndim
dim()
axis
How to create an array with random integers from 0 to 10 of size 5?
np.randint(0, 10, size=5)
np.random.randint(0, 10, 5)
np.random.rand(5)
a and b
All of the above
What does np.mean(np.array([1,2,3])) return?
1.0
3
2.0
1.5
Error
What is the output of np.array([[1, 2], [3, 4]]).T?
Original array
Flattened array
Transposed array
Identity matrix
Random matrix
How to generate 10 random numbers from normal distribution?
np.random.normal(0, 1, 10)
np.random.randn(10)
np.normal(10)
Both a and b
None of the above
What is np.linspace(0, 1, 5) used for?
Evenly spaced integers
Evenly spaced floats
Logarithmic spacing
Random values
Binary values
What is broadcasting in NumPy?
Adding two arrays of unequal shapes
Multiplying matrices
Flattening a 2D array
Removing missing values
Iterating over arrays
Which method sorts an array in-place?
np.sort()
array.sort()
np.arrange()
array.order()
np.order()
