Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
NumPy - Array Operations
What will be the output of this code?
import numpy as np
arr = np.array([True, False, True])
result = np.logical_not(arr)
print(result)
A[True False True]
B[False True False]
C[True True True]
D[False False False]
Step-by-Step Solution
Solution:
  1. Step 1: Apply logical NOT element-wise

    Logical NOT flips True to False and False to True for each element.
  2. Step 2: Calculate the output array

    Input: [True, False, True] becomes [False, True, False].
  3. Final Answer:

    [False True False] -> Option B
  4. Quick Check:

    Logical NOT flips booleans = [False True False] [OK]
Quick Trick: NOT flips True to False and vice versa [OK]
Common Mistakes:
  • Confusing NOT with AND/OR
  • Expecting no change
  • Using bitwise NOT (~) incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes