Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q6 of 15
NumPy - Array Data Types
Find the error in this code snippet:
import numpy as np
arr = np.array([1, 2, 3], dtype='int128')
print(arr)
AArray elements must be floats
BMissing import statement
Cint128 is not a valid numpy dtype
DSyntax error in array creation
Step-by-Step Solution
Solution:
  1. Step 1: Check valid numpy integer types

    numpy supports int8, int16, int32, int64 but not int128.
  2. Step 2: Identify error cause

    Using 'int128' as dtype causes a ValueError because it is invalid.
  3. Final Answer:

    int128 is not a valid numpy dtype -> Option C
  4. Quick Check:

    Only int8, int16, int32, int64 are valid integer dtypes [OK]
Quick Trick: Use only supported integer dtypes: int8 to int64 [OK]
Common Mistakes:
  • Assuming int128 exists
  • Ignoring dtype errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes