C. Using '&&' instead of '&' for combining conditions
D. No error, code runs fine
Solution
Step 1: Identify operator error
NumPy uses bitwise operators '&' and '|' for element-wise logical operations, not '&&'.
Step 2: Correct operator usage
Replace '&&' with '&' and add parentheses around each condition.
Final Answer:
Using '&&' instead of '&' for combining conditions -> Option C
Quick Check:
'&&' is invalid in NumPy, use '&' with parentheses [OK]
Hint: Use '&' not '&&' for NumPy condition combining [OK]
Common Mistakes:
Using '&&' from other languages
Not adding parentheses around conditions
Using Python 'and' instead of '&'
5. You have a NumPy array data = np.array([10, 15, 20, 25, 30, 35]). You want to select elements that are either less than 20 or greater than or equal to 30, but NOT equal to 15. Which code correctly filters data?