wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Numpy

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is a correct syntax to create a NumPy array?

a)

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

b)

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

c)

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

2.

Which of the following arrays is a two dimensional (2-D) array?

a)

[1, 2, 3, 4, 5]

b)

[[1, 2, 3], [4, 5, 6]]

c)

42

3.

What is a correct syntax to print the first item of an array?

a)

print(myArr,1)

b)

print(myArr[0])

c)

print(myArr[1])

4.

Which syntax would print every other item from the array below:

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

a)

print(arr[1:3:5:7])

b)

print(arr(0: step = 2))

c)

print(arr[::2])

5.

What is a correct syntax to print the number 8 from the array below:

arr = np.array([[1,2,3,4,5], [6,7,8,9,10]])

a)

print(arr[1, 2])

b)

print(arr[7, 2])

c)

print(arr[3, 0])

6.

Which syntax would print the last 4 numbers from the array below:

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

a)

print(arr[4])

b)

print(arr[3:])

c)

print(arr[4:])

d)

print(arr[:4])

7.

Which syntax would print every other item from the array below:

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

a)

print(arr[1:3:5:7])

b)

print(arr(0: step = 2))

c)

print(arr[::2])

8.

What is a correct syntax to create a Pandas Series from a Python list?

a)

pd.getSeries(mylist)

b)

pd.createSeries(mylist)

c)

pd.Series(mylist)

9.

What is a correct syntax to return the first value of a Pandas Series?

a)

get(myseries, 0)

b)

myseries[0]

c)

myseries.get(0)

10.

What is a correct syntax to add the lables "x", "y", and "z" to a Pandas Series?

a)

pd.Series(mylist, names = ["x", "y", "z"])

b)

pd.Series(mylist, lables = ["x", "y", "z"])

c)

pd.Series(mylist, index = ["x", "y", "z"])