Bird
0
0

Given arrays:

hard📝 Application Q9 of 15
NumPy - Array Operations
Given arrays:
x = np.array([1, 2, 3])
y = np.array([2, 2, 2])

Which code uses a ufunc to compute element-wise comparison returning a boolean array?
Anp.greater(x, y)
Bnp.compare(x, y)
Cx > y
Dnp.compare_arrays(x, y)
Step-by-Step Solution
Solution:
  1. Step 1: Identify ufunc for element-wise comparison

    np.greater compares elements and returns boolean array.
  2. Step 2: Check other options

    np.compare and np.compare_arrays do not exist; x > y is valid but not a ufunc call.
  3. Final Answer:

    np.greater(x, y) -> Option A
  4. Quick Check:

    Element-wise comparison ufunc = np.greater [OK]
Quick Trick: Comparison ufuncs include np.greater, np.less, np.equal [OK]
Common Mistakes:
  • Using invalid function names
  • Confusing operator with ufunc
  • Assuming all comparisons are ufuncs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes