Bird
0
0

What does the NumPy function np.logical_or do when applied to two boolean arrays?

easy📝 Conceptual Q1 of 15
NumPy - Array Operations
What does the NumPy function np.logical_or do when applied to two boolean arrays?
AReturns the sum of the two arrays
BReturns True only if both elements in the corresponding positions are True
CReturns the negation of the first array
DReturns True if at least one element in the corresponding positions is True
Step-by-Step Solution
Solution:
  1. Step 1: Understand the logical_or operation

    The np.logical_or function compares two arrays element-wise and returns True if either element is True.
  2. Step 2: Compare with other options

    Returns True only if both elements in the corresponding positions are True describes logical AND, Returns the negation of the first array describes logical NOT, and Returns the sum of the two arrays is unrelated to logical operations.
  3. Final Answer:

    Returns True if at least one element in the corresponding positions is True -> Option D
  4. Quick Check:

    Logical OR = Returns True if either is True [OK]
Quick Trick: Logical OR returns True if any input is True [OK]
Common Mistakes:
  • Confusing logical OR with AND
  • Thinking it negates values
  • Assuming it sums values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes