wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

NumPy

Total questions: 16

Worksheet time: 16mins

Name
Class
Date
1.

What makes NumPy arrays more efficient than standard Python lists?

a)

NumPy arrays take performance-enhancing supplements

b)

They rely on GPU acceleration by default

c)

They use fixed data types and store elements in contiguous memory blocks

d)

They can store more elements than lists

2.

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])

a)

·        [[10, 20], [40, 50]]

b)

·           [[20, 30], [50, 60]]

c)

[[40, 50, 60], [70, 80, 90]]

d)

[[50], [80]]

3.

When you run np.zeros((3, 4)), what is the shape of the created array?

a)

Rectangle Shape

b)

(3, 4)

c)

(3, 3)

d)

(4, 3)

4.

What is the output of np.arange(10)?

a)

An array from 1 to 10

b)

An array from 0 to 9

c)

A new superhero group, 'The Arrayngers'

d)

A range object

5.

What does the np.linspace function return?

a)

Creates an array with values that are logarithmically spaced

b)

It lines up the numbers for a race

c)

Creates an array of fixed length filled with random values

d)

Creates an array with linearly spaced values

6.

What does the .ndim attribute of a NumPy array return?

a)

The total number of elements in the array

b)

The shape of the array as a tuple

c)

The number of dimensions (axes) of the array

d)

The data type of the array's elements

7.

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)

a)

(2, 2)

b)

(3, 2, 2)

c)

(2, 2, 2)

d)

(2, 4)

8.

What does the function np.full((2, 2), 5) do?

a)

Creates a 2x2 array filled with 5s

b)

Creates a 5x5 array filled with 2s

c)

Creates a 2x2 array filled with zeros

d)

Creates an empty 2x2 array

9.

What does np.random.randint(10, 100, (2, 3)) do?

a)

Creates a 2x3 array of random integers between 0 and 10

b)

Creates a 2x3 array of random integers between 10 and 100

c)

Creates a 3x2 array filled with 10s

d)

Creates a 2x3 array of random floats between 10 and 100

10.

What does np.random.rand(3, 3) return?

a)

A 3x3 array of random integers

b)

A 3x3 array of random floats between 0 and 1

c)

A 3x3 array of zeros

d)

A single random float number

11.

What does np.random.randn(3, 3) return?

a)

A 3x3 array of random floats between 0 and 1

b)

A 3x3 array of random integers

c)

A 3x3 array of random numbers from a standard normal distribution

d)

A 3x3 array of ones

12.

What does np.eye(4) create?

a)

A 4x4 matrix with all elements as 1

b)

A 4x4 matrix with 1s on the diagonal and 0s elsewhere

c)

A 4x4 matrix with random values

d)

A 4x4 matrix of zeros

13.

What does np.sort(arr)[::-1] do when arr = np.array([3, 1, 4])?

a)

Sorts the array in ascending order

b)

Reverses the array as-is

c)

Sorts the array in descending order

d)

Leaves the array unchanged

14.

What does np.concatenate((arr1, arr2), axis=0) do?

a)

Joins two arrays side by side (column-wise)

b)

Joins two arrays vertically (row-wise)

c)

Multiplies two arrays

d)

Sorts the arrays in ascending order

15.

What does np.stack((arr1, arr2)) do when arr1 and arr2 are 1D arrays of the same shape?

a)

Joins them into a single flat array

b)

Adds a new axis and stacks the arrays along that axis

c)

Multiplies the two arrays element-wise

d)

Fills one array with the values of the other

16.

What does np.split(arr, 3) do when arr has 6 elements?

a)

Merges 3 arrays into one

b)

Splits the array into 3 equal parts

c)

Sorts the array into 3 chunks

d)

Duplicates the array 3 times