Bird
0
0

What is the output of the following code?

medium📝 Predict Output Q4 of 15
NumPy - Array Operations
What is the output of the following code?
import numpy as np
x = np.array([True, False, True])
y = np.array([False, False, True])
result = np.logical_and(x, y)
print(result)
A[True False True]
B[False False True]
C[False True False]
D[True True True]
Step-by-Step Solution
Solution:
  1. Step 1: Perform element-wise logical AND

    Compare each element: True AND False = False, False AND False = False, True AND True = True.
  2. Step 2: Construct the result array

    The result is [False, False, True].
  3. Final Answer:

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

    Logical AND of arrays = [False False True] [OK]
Quick Trick: AND returns True only if both are True [OK]
Common Mistakes:
  • Mixing up True and False
  • Using OR instead of AND
  • Misreading array elements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes