wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Introduction to NumPy (easy)

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

line 1: import numpy as np

line 2: array = ______ ([1,2,3,4,5])

array

FILL IN THE BLANK

a)

np.Array

b)
np.array
c)
numpy.array
d)
np.arrayy
2.

Line 1: array = np.array([1,2,3,4,5])

Line 2: print(array[2])

What will the code print?

a)
3
b)
6
c)
4
d)
2
3.

import numpy as np

array = np.array([1,2,3,4,5])

array[1] = 7

print(array)

What does line 3 do?

a)
Prints the 'array' without any changes.
b)
Updates the value at index 1 in the 'array' to 7.
c)
Adds a new element with the value 7 at index 1 in the 'array'.
d)
Deletes the element at index 1 in the 'array'.
4.

import numpy as np

array = np.array([1,2,3,4,5])

array[1] = 7

print(array)

What will the code print?

a)
[1,7,7,4,5]
b)
[1,7,3,7,5]
c)
[1,2,3,4,5]
d)
[1,7,3,4,5]
5.

import numpy as np

array = np.array([1,2,3,4,5])

array += 10

print(array)

What does this code print?

a)
[21, 22, 23, 24, 25]
b)
[6, 7, 8, 9, 10]
c)
[11, 12, 13, 14, 15]
d)
[10, 10, 10, 10, 10]
6.

import numpy as np

array = np.array([1,2,3,4,5])

sum_all = np.sum(array)

print(sum_all)

What is the result of this code?

a)
10
b)
15
c)
20
d)
25
7.

import numpy as np

array = np.array([1,2,3,4,5])

sum_all = ______(array)

print(sum_all)

Fill in the blank

a)

np.Sum

b)

np.addition

c)
np.sum
d)
np.add
8.

Line 1: array = np.array([1,2,3,4,5])

Line 2: print(array[___])

The code returns the following:

3

What should be in the blank?

a)
6
b)
4
c)
1
d)
2
9.

import numpy as np

array = np.array([1,2,3,4,5])

array[__] = 7

print(array)

The code returns this:

[1,2,7,4,5]

What should be in the blank?

a)
3
b)
6
c)
8
d)
2
10.

import numpy as np

array = np.array([20,30,40,50,60])

sum_all = np.sum,(array)

print(sum_allincluded)

What does the code print?

a)
15
b)
25
c)
20
d)
10
e)

error