Bird
0
0

What is the output of this code?

medium📝 Predict Output Q4 of 15
NumPy - Array Data Types
What is the output of this code?
import numpy as np
arr = np.array([1, 2, 3], dtype='float32')
print(arr.dtype)
Aint64
Bfloat32
Cfloat64
Dobject
Step-by-Step Solution
Solution:
  1. Step 1: Understand dtype parameter

    The array is created with dtype='float32', so elements are 32-bit floats.
  2. Step 2: Check printed dtype

    Printing arr.dtype shows the actual data type of array elements, which is float32.
  3. Final Answer:

    float32 -> Option B
  4. Quick Check:

    dtype prints as specified = B [OK]
Quick Trick: print(arr.dtype) shows the specified dtype [OK]
Common Mistakes:
  • Assuming default float64 instead of float32
  • Confusing dtype output with array values
  • Expecting int64 because of integer inputs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes