Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
NumPy - Array Data Types
What will be the output of this code?
import numpy as np
arr = np.array([True, False, True])
print(arr & np.array([False, False, True]))
A[False False True]
B[True False True]
C[True True True]
D[False False False]
Step-by-Step Solution
Solution:
  1. Step 1: Understand bitwise AND on boolean arrays

    Element-wise AND: True & False = False, False & False = False, True & True = True.
  2. Step 2: Apply AND operation element-wise

    Results: [False, False, True].
  3. Final Answer:

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

    Boolean AND result = [False False True] [OK]
Quick Trick: Use & for element-wise AND on boolean numpy arrays [OK]
Common Mistakes:
  • Using && which is invalid in numpy
  • Expecting OR operation result
  • Confusing with logical_and function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes