Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q13 of 15
NumPy - Creating Arrays
What will be the output of this code?
import numpy as np
arr = np.empty((2,2))
print(arr)
ASyntaxError
B[[1. 1.] [1. 1.]]
C[[0. 0.] [0. 0.]]
DAn array with random uninitialized values
Step-by-Step Solution
Solution:
  1. Step 1: Understand np.empty() output

    np.empty() creates an array without initializing values, so the content is random garbage data from memory.
  2. Step 2: Predict printed output

    The printed array will show unpredictable float numbers, not zeros or ones.
  3. Final Answer:

    An array with random uninitialized values -> Option D
  4. Quick Check:

    np.empty() output = random uninitialized values [OK]
Quick Trick: np.empty() shows random values, not zeros or ones [OK]
Common Mistakes:
  • Expecting zeros or ones in output
  • Thinking np.empty() initializes values
  • Confusing with np.zeros() or np.ones()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes