0
0
Pandasdata~10 mins

When to use NumPy over Pandas - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a NumPy array from a list.

Pandas
import numpy as np
arr = np.[1]([1, 2, 3, 4])
print(arr)
Drag options to blanks, or click blank then click option'
Aarray
BDataFrame
CSeries
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using pandas functions like DataFrame or Series instead of NumPy array.
Trying to use list() which is a Python built-in, not NumPy.
2fill in blank
medium

Complete the code to calculate the mean of a NumPy array.

Pandas
import numpy as np
arr = np.array([10, 20, 30, 40])
mean_value = arr.[1]()
print(mean_value)
Drag options to blanks, or click blank then click option'
Amean
Bmode
Cmedian
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum() which adds all elements but does not calculate average.
Using median() which finds the middle value, not the average.
3fill in blank
hard

Fix the error in the code to create a NumPy array of zeros with length 5.

Pandas
import numpy as np
zeros = np.[1](5)
print(zeros)
Drag options to blanks, or click blank then click option'
Azeroes
Bones
Cempty
Dzeros
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'zeroes' which is a common misspelling.
Using 'empty' which creates an uninitialized array, not zeros.
4fill in blank
hard

Fill both blanks to create a NumPy array and calculate its standard deviation.

Pandas
import numpy as np
arr = np.[1]([2, 4, 6, 8])
std_dev = arr.[2]()
print(std_dev)
Drag options to blanks, or click blank then click option'
Aarray
Bmean
Cstd
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean() instead of std() for standard deviation.
Using sum() which adds elements but does not calculate deviation.
5fill in blank
hard

Fill all three blanks to create a NumPy array, filter values greater than 3, and calculate their sum.

Pandas
import numpy as np
arr = np.[1]([1, 2, 3, 4, 5])
filtered = arr[arr [2] 3]
result = filtered.[3]()
print(result)
Drag options to blanks, or click blank then click option'
Aarray
B>
Csum
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > for filtering.
Using mean() instead of sum() for the final calculation.