0
0
NumPydata~10 mins

Why NumPy over Python lists - Test Your Understanding

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

Complete the code to import the NumPy library with its common alias.

NumPy
import [1] as np
Drag options to blanks, or click blank then click option'
Ascipy
Bpandas
Cmatplotlib
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong library like pandas or matplotlib.
Not using the alias 'np' which is a common convention.
2fill in blank
medium

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

NumPy
arr = np.[1]([1, 2, 3, 4])
Drag options to blanks, or click blank then click option'
Alist
Barray
Cmatrix
Dseries
Attempts:
3 left
💡 Hint
Common Mistakes
Using np.list() which does not exist.
Confusing arrays with matrices or series.
3fill in blank
hard

Fix the error in the code to calculate the mean of a NumPy array.

NumPy
mean_value = arr.[1]()
Drag options to blanks, or click blank then click option'
Amean
Baverage
Cmedian
Dmode
Attempts:
3 left
💡 Hint
Common Mistakes
Using average() which is not a NumPy array method.
Confusing mean with median or mode.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if the length is greater than 3.

NumPy
{word: [1] for word in words if [2] > 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Dword.length
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.length which is not valid in Python.
Using the word itself instead of its length.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts only if the count is greater than 0.

NumPy
result = [1]: [2] for [3], count in data.items() if count > 0}
Drag options to blanks, or click blank then click option'
Aword.upper()
Bcount
Cword
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original word as key without converting to uppercase.
Mixing up keys and values in the comprehension.