Bird
0
0

Which of the following is the correct way to create a numpy array of complex numbers with type complex64?

easy📝 Syntax Q12 of 15
NumPy - Array Data Types
Which of the following is the correct way to create a numpy array of complex numbers with type complex64?
Anp.array([1+2j, 3+4j], dtype='complex64')
Bnp.array([1+2j, 3+4j], dtype='int64')
Cnp.array([1, 2, 3], dtype='complex64')
Dnp.array([1+2, 3+4], dtype='complex64')
Step-by-Step Solution
Solution:
  1. Step 1: Check the array elements

    The elements must be complex numbers, so they need an imaginary part like 1+2j.
  2. Step 2: Check the dtype argument

    Using dtype='complex64' correctly sets the array to complex numbers with 64-bit precision.
  3. Final Answer:

    np.array([1+2j, 3+4j], dtype='complex64') -> Option A
  4. Quick Check:

    Complex elements + complex64 dtype = correct array [OK]
Quick Trick: Use complex literals with 'j' and set dtype to complex64 [OK]
Common Mistakes:
  • Using integer dtype with complex numbers
  • Missing imaginary part in elements
  • Using invalid dtype strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes