wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

NumPy Quiz

Total questions: 21

Worksheet time: 11mins

Name
Class
Date
1.

What is NumPy primarily used for?

a)

Creating GUIs

b)

File handling

c)

Numerical computations

d)

Web development

e)

Game development

2.

What function creates an array with values [0, 1, 2, 3, 4]?

a)

np.arange(5)

b)

np.range(5)

c)

np.linspace(0,5)

d)

np.array(5)

e)

np.series(5)

3.

How can you create an array of all ones with shape (2,3)?

a)

np.ones((2,3))

b)

np.ones[2,3]

c)

np.one((2,3))

d)

np.full((2,3), 1.0)

e)

Both a and d

4.

What will be the output of np.array([1, 2, 3]) * 2?

a)

[1, 2, 3, 1, 2, 3]

b)

[2, 4, 6]

c)

[1, 2, 3, 2]

d)

[1, 4, 9]

e)

Error

5.

What does np.array([1, 2, 3]).ndim return?

a)

1

b)

2

c)

3

d)

0

e)

Error

6.

What will np.arange(1, 10, 2) output?

a)

[1, 2, 3, 4, 5, 6, 7, 8, 9]

b)

[1, 3, 5, 7, 9]

c)

[1, 2, 4, 6, 8]

d)

[2, 4, 6, 8, 10]

e)

Error

7.

What is the output of np.array([[1, 2], [3, 4]]).shape?

a)

(2, 2)

b)

2

c)

(4,)

d)

(2,)

e)

(1, 4)

8.

Which NumPy function creates a sequence of evenly spaced numbers over a specified interval?

a)

arange()

b)

range()

c)

linspace()

d)

series()

e)

spacing()

9.

Which of the following will create a NumPy array?

a)

np.array([1, 2, 3])

b)

np.array(range(3))

c)

np.array((1, 2, 3))

d)

All of the above

e)

Only a and b

10.

What will np.sum(np.array([1,2,3])) return?

a)

6

b)

[6]

c)

3

d)

Error

e)

None

11.

Which of the following is not a NumPy data type?

a)

int32

b)

float64

c)

bool_

d)

dict

e)

complex128

12.

What does np.eye(3) create?

a)

A 3x3 matrix of ones

b)

A 3x3 identity matrix

c)

A 3x3 matrix of zeros

d)

A 3x1 matrix

e)

A diagonal matrix with 3s

13.

What does np.full((2, 2), 7) do?

a)

Creates a 2x2 matrix filled with 7s

b)

Creates a 2-element array

c)

Fills the array with random numbers

d)

Creates a 2x7 matrix

e)

Error

14.

Which attribute returns the number of dimensions of an array?

a)

shape

b)

size

c)

ndim

d)

dim()

e)

axis

15.

How to create an array with random integers from 0 to 10 of size 5?

a)

np.randint(0, 10, size=5)

b)

np.random.randint(0, 10, 5)

c)

np.random.rand(5)

d)

a and b

e)

All of the above

16.

What does np.mean(np.array([1,2,3])) return?

a)

1.0

b)

3

c)

2.0

d)

1.5

e)

Error

17.

What is the output of np.array([[1, 2], [3, 4]]).T?

a)

Original array

b)

Flattened array

c)

Transposed array

d)

Identity matrix

e)

Random matrix

18.

How to generate 10 random numbers from normal distribution?

a)

np.random.normal(0, 1, 10)

b)

np.random.randn(10)

c)

np.normal(10)

d)

Both a and b

e)

None of the above

19.

What is np.linspace(0, 1, 5) used for?

a)

Evenly spaced integers

b)

Evenly spaced floats

c)

Logarithmic spacing

d)

Random values

e)

Binary values

20.

What is broadcasting in NumPy?

a)

Adding two arrays of unequal shapes

b)

Multiplying matrices

c)

Flattening a 2D array

d)

Removing missing values

e)

Iterating over arrays

21.

Which method sorts an array in-place?

a)

np.sort()

b)

array.sort()

c)

np.arrange()

d)

array.order()

e)

np.order()