What does the np.clip() function do in NumPy?
Correct answer
A. Clips values outside a specified range to the range's boundaries
16 views
A. Clips values outside a specified range to the range's boundaries
16 views
np.clip() limits values to a given range: anything below the minimum becomes the minimum and anything above the maximum becomes the maximum. np.clip([1, 5, 12], 2, 10) returns [2, 5, 10].
It is commonly used to cap outliers or keep pixel values within 0–255.
Want more practice? Try the full set of Data Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.