0
0
NumPydata~10 mins

np.min() and np.max() in NumPy - Interactive Code Practice

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

Complete the code to find the minimum value in the array.

NumPy
import numpy as np
arr = np.array([3, 7, 1, 9, 5])
min_value = np.[1](arr)
print(min_value)
Drag options to blanks, or click blank then click option'
Amax
Bmean
Csum
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using np.max() instead of np.min()
Trying to use Python's built-in min() without numpy
2fill in blank
medium

Complete the code to find the maximum value in the 2D array.

NumPy
import numpy as np
arr = np.array([[4, 2, 8], [1, 7, 5]])
max_value = np.[1](arr)
print(max_value)
Drag options to blanks, or click blank then click option'
Amax
Bmin
Cmedian
Daverage
Attempts:
3 left
💡 Hint
Common Mistakes
Using np.min() instead of np.max()
Trying to use Python's built-in max() without numpy
3fill in blank
hard

Fix the error in the code to correctly find the minimum value along axis 0.

NumPy
import numpy as np
arr = np.array([[10, 20], [5, 15]])
min_values = np.min(arr, [1]=0)
print(min_values)
Drag options to blanks, or click blank then click option'
Aaxis
Baxes
Cdim
Ddirection
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'axes' instead of 'axis'
Using 'dim' or 'direction' which are invalid parameters
4fill in blank
hard

Fill both blanks to create a dictionary of max values for each column in the array.

NumPy
import numpy as np
arr = np.array([[3, 6, 9], [2, 8, 5]])
max_dict = {i: np.[1](arr, [2]=0)[i] for i in range(arr.shape[1])}
print(max_dict)
Drag options to blanks, or click blank then click option'
Amax
Bmin
Caxis
Ddim
Attempts:
3 left
💡 Hint
Common Mistakes
Using np.min() instead of np.max()
Using 'dim' instead of 'axis' as parameter
5fill in blank
hard

Fill all three blanks to create a dictionary of min values for each row in the array.

NumPy
import numpy as np
arr = np.array([[7, 4, 1], [3, 9, 6]])
min_dict = {i: np.[1](arr, [2]=1)[[3]] for i in range(arr.shape[0])}
print(min_dict)
Drag options to blanks, or click blank then click option'
Amax
Bmin
Caxis
Di
Attempts:
3 left
💡 Hint
Common Mistakes
Using np.max() instead of np.min()
Using wrong parameter name instead of 'axis'
Using a fixed number instead of the loop variable