NUMPY BASIC EXERCISE 9


Create an array and print its dtype as complex

In this exercise we are going to create an array and print it while keeping its data type as complex.

Code

# dtype parameter 
import numpy as np 
arr = np.array([1, 2, 3], dtype = complex) 
print(arr)

Output

[1.+0.j 2.+0.j 3.+0.j]

Code Editor

import numpy as np arr = np.array([1, 2, 3], dtype = complex) print(arr)