NEW
Font size
WorksheetsNumPy
Total questions: 16
Worksheet time: 16mins
What makes NumPy arrays more efficient than standard Python lists?
NumPy arrays take performance-enhancing supplements
They rely on GPU acceleration by default
They use fixed data types and store elements in contiguous memory blocks
They can store more elements than lists
What will be the output of the following code?
arr = np.array([[10, 20, 30], [40, 50, 60], [70, 80, 90]])
print(arr[1:3, 1:2])
· [[10, 20], [40, 50]]
· [[20, 30], [50, 60]]
[[40, 50, 60], [70, 80, 90]]
[[50], [80]]
When you run np.zeros((3, 4)), what is the shape of the created array?
Rectangle Shape
(3, 4)
(3, 3)
(4, 3)
What is the output of np.arange(10)?
An array from 1 to 10
An array from 0 to 9
A new superhero group, 'The Arrayngers'
A range object
What does the np.linspace function return?
Creates an array with values that are logarithmically spaced
It lines up the numbers for a race
Creates an array of fixed length filled with random values
Creates an array with linearly spaced values
What does the .ndim attribute of a NumPy array return?
The total number of elements in the array
The shape of the array as a tuple
The number of dimensions (axes) of the array
The data type of the array's elements
What will be the output of the following code?
import numpy as np
arr = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
print(arr.shape)
(2, 2)
(3, 2, 2)
(2, 2, 2)
(2, 4)
What does the function np.full((2, 2), 5) do?
Creates a 2x2 array filled with 5s
Creates a 5x5 array filled with 2s
Creates a 2x2 array filled with zeros
Creates an empty 2x2 array
What does np.random.randint(10, 100, (2, 3)) do?
Creates a 2x3 array of random integers between 0 and 10
Creates a 2x3 array of random integers between 10 and 100
Creates a 3x2 array filled with 10s
Creates a 2x3 array of random floats between 10 and 100
What does np.random.rand(3, 3) return?
A 3x3 array of random integers
A 3x3 array of random floats between 0 and 1
A 3x3 array of zeros
A single random float number
What does np.random.randn(3, 3) return?
A 3x3 array of random floats between 0 and 1
A 3x3 array of random integers
A 3x3 array of random numbers from a standard normal distribution
A 3x3 array of ones
What does np.eye(4) create?
A 4x4 matrix with all elements as 1
A 4x4 matrix with 1s on the diagonal and 0s elsewhere
A 4x4 matrix with random values
A 4x4 matrix of zeros
What does np.sort(arr)[::-1] do when arr = np.array([3, 1, 4])?
Sorts the array in ascending order
Reverses the array as-is
Sorts the array in descending order
Leaves the array unchanged
What does np.concatenate((arr1, arr2), axis=0) do?
Joins two arrays side by side (column-wise)
Joins two arrays vertically (row-wise)
Multiplies two arrays
Sorts the arrays in ascending order
What does np.stack((arr1, arr2)) do when arr1 and arr2 are 1D arrays of the same shape?
Joins them into a single flat array
Adds a new axis and stacks the arrays along that axis
Multiplies the two arrays element-wise
Fills one array with the values of the other
What does np.split(arr, 3) do when arr has 6 elements?
Merges 3 arrays into one
Splits the array into 3 equal parts
Sorts the array into 3 chunks
Duplicates the array 3 times
