NEW
Font size
WorksheetsNumPy Basics Quiz
Total questions: 30
Worksheet time: 15mins
What does NumPy stand for?
Numerical Python
Numbers in Python
Numeric Python
NumberPy
Which of the following is the correct way to import NumPy?
import numpy as npy
import numpy as np
import numpy
import num as np
How do you create a NumPy array?
np.array([1, 2, 3])
np.array{[1, 2, 3]}
np.array((1, 2, 3))
np.array[1, 2, 3]
Which function is used to create an array filled with zeros?
np.empty()
np.zeros()
np.zeros_like()
np.fill()
What function is used to create an identity matrix in NumPy?
np.eye()
np.identity()
np.ones()
np.ident()
Which method is used to find the shape of a NumPy array?
np.shape()
array.shape
array.size
array.dim()
What does the ndim attribute of a NumPy array return?
The number of elements in the array
The number of dimensions of the array
The shape of the array
The data type of the array elements
What will the output of np.arange(3, 10, 2) be?
[3, 4, 5, 6, 7, 8, 9]
[3, 5, 7, 9]
[3, 5, 7, 8, 9]
[3, 4, 5, 6]
What does np.linspace(0, 5, 10) do?
Creates an array from 0 to 5 with 10 elements, equally spaced
Creates an array of 10 elements from 0 to 5, excluding 5
Creates an array from 0 to 10
Creates a list from 0 to 5
Which of the following reshapes an array of shape (4,) to (2, 2)?
array.reshape(4)
array.reshape(2, 2)
array.shape(2, 2)
np.reshape(array, (4, 1))
How do you create a 1D array of ones with length 4?
np.ones([4, 1])
np.ones((4,))
np.ones((1, 4))
np.ones(4)
What is the output of np.array([1, 2, 3]) * 2?
[1, 2, 3, 1, 2, 3]
[1, 4, 6]
[2, 4, 6]
Error
What does the dtype attribute of a NumPy array specify?
Number of elements in the array
Type of the elements in the array
Dimensions of the array
Shape of the array
Which of the following can be used to get the sum of elements in a NumPy array?
np.add()
np.sum()
np.cumsum()
np.aggregate()
How would you calculate the mean of all elements in a NumPy array?
np.mean(array)
np.average(array)
np.sum(array)
array.mean()
Which function is used to stack arrays vertically in NumPy?
np.vstack()
np.hstack()
np.stack()
np.concatenate()
How can you transpose a NumPy array?
np.transpose(array)
np.flip(array)
array.transpose()
array.T
What does np.random.rand(2, 3) generate?
A 2x3 array with random floats between 0 and 1
A 2x3 array with random integers between 0 and 10
A 3x2 array with random floats
A list of random floats
What is the shape of np.ones((3, 4)).T?
(4, 3)
(3, 4)
(4,)
(12,)
What function will return the maximum value in an array?
np.maximum()
np.max()
np.argmax()
np.highest()
How do you flatten a multidimensional array in NumPy?
array.flatten()
array.reshape(-1)
np.flatten(array)
Both a and b
Which of these will broadcast a NumPy array of shape (3, 1) with another of shape (1, 3)?
(3, 3)
(3,)
(1,)
(1, 1)
What is the default data type of NumPy arrays?
int
float
double
complex
How do you convert a list to a NumPy array?
np.convert()
np.array()
np.fromlist()
np.list()
What is the function np.dot() used for?
Matrix addition
Matrix multiplication
Element-wise multiplication
Matrix transpose
What will np.log(np.e) return?
0
1
e
Error
How would you check if any element in an array is True?
np.all()
np.any()
np.bool()
np.check()
Which of the following is used to return a copy of an array?
array.view()
array.copy()
np.array_copy()
array.clone()
What does the function np.sqrt() compute?
Square root of elements in the array
Square of elements in the array
Inverse of the elements
Natural logarithm of the elements
What does np.append() do?
Inserts elements at a given index
Appends an element to the end of an array
Concatenates two arrays
Returns a sorted array
