Bird
0
0

What is the output dtype of this code?

medium📝 Predict Output Q13 of 15
NumPy - Array Data Types
What is the output dtype of this code?
import numpy as np
arr = np.array([1.5, 2.5], dtype=np.float16)
print(arr.dtype)
Afloat32
Bfloat64
Cint16
Dfloat16
Step-by-Step Solution
Solution:
  1. Step 1: Check dtype argument in np.array

    The array is created with dtype=np.float16, so the array elements are stored as float16.
  2. Step 2: Print dtype attribute

    Printing arr.dtype will show float16 as the data type.
  3. Final Answer:

    float16 -> Option D
  4. Quick Check:

    dtype set to float16 prints float16 [OK]
Quick Trick: dtype attribute shows the array's float type [OK]
Common Mistakes:
  • Assuming default float64 dtype
  • Confusing float16 with float32
  • Thinking dtype prints data values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes