0
0
NumPydata~10 mins

What is NumPy - Interactive Quiz & Practice

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 the common alias.

NumPy
import [1] as np
Drag options to blanks, or click blank then click option'
Anumpy
Bmatplotlib
Cpandas
Dscipy
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong library name like 'pandas' or 'matplotlib'.
Forgetting to use the alias 'np' after import.
2fill in blank
medium

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

NumPy
import numpy as np
arr = np.[1]([1, 2, 3, 4])
Drag options to blanks, or click blank then click option'
Alist
Bdataframe
Cmatrix
Darray
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'list' which is a Python type, not a NumPy function.
Using 'dataframe' which belongs to pandas library.
3fill in blank
hard

Fix the error in the code to get the shape of a NumPy array.

NumPy
import numpy as np
arr = np.array([1, 2, 3])
shape = arr.[1]
Drag options to blanks, or click blank then click option'
Ashape()
Bshape
Csize()
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses like a function call (e.g., shape()).
Using 'size()' which returns total elements, not shape.
4fill in blank
hard

Fill both blanks to create a 2x2 NumPy array filled with zeros.

NumPy
import numpy as np
zeros_array = np.[1]((2, [2]))
Drag options to blanks, or click blank then click option'
Azeros
Bones
C3
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ones' instead of 'zeros'.
Using wrong shape dimensions like (2, 3).
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each word to its length if length is greater than 3.

NumPy
words = ['apple', 'bat', 'car', 'door']
lengths = { [1]: [2] for [3] in words if len([3]) > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not using len() to get the length.