Bird
0
0

Which of the following is the correct syntax to create a numpy array of type int64?

easy📝 Syntax Q3 of 15
NumPy - Array Data Types
Which of the following is the correct syntax to create a numpy array of type int64?
Anp.array([1, 2, 3], dtype=int32)
Bnp.array([1, 2, 3], type='int64')
Cnp.array([1, 2, 3], type=int64)
Dnp.array([1, 2, 3], dtype='int64')
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct parameter for data type

    In numpy, the parameter to specify data type is 'dtype'.
  2. Step 2: Check correct usage of dtype

    It should be a string or numpy type, so 'dtype="int64"' is correct.
  3. Final Answer:

    np.array([1, 2, 3], dtype='int64') -> Option D
  4. Quick Check:

    Use dtype='int64' to specify 64-bit integers [OK]
Quick Trick: Use dtype='int64' to set 64-bit integer type [OK]
Common Mistakes:
  • Using 'type' instead of 'dtype'
  • Passing dtype as int32 instead of int64

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes