Bird
0
0

Which NumPy function is used to perform element-wise logical NOT on a boolean array?

easy📝 Conceptual Q2 of 15
NumPy - Array Operations
Which NumPy function is used to perform element-wise logical NOT on a boolean array?
Anp.logical_and
Bnp.logical_not
Cnp.logical_or
Dnp.invert
Step-by-Step Solution
Solution:
  1. Step 1: Identify the function for logical NOT

    The function np.logical_not performs element-wise negation of boolean values.
  2. Step 2: Differentiate from other functions

    np.logical_and and np.logical_or perform AND and OR respectively. np.invert can invert bits but is not recommended for boolean arrays.
  3. Final Answer:

    np.logical_not -> Option B
  4. Quick Check:

    Logical NOT function = np.logical_not [OK]
Quick Trick: Use np.logical_not for element-wise NOT on booleans [OK]
Common Mistakes:
  • Using np.invert which may cause unexpected results
  • Confusing NOT with AND or OR
  • Using bitwise operators instead

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes