Python Practice › NumPy Programs › Program 100

Complex dtype array

EasyNumPy Programs · 100 of 100

Write a NumPy program to create an array with complex dtype.

Advertisement
Input
[5, 4]
Output
[5.+0.j 4.+0.j]

Approach

  1. dtype=complex.

Solution

Python
import numpy as npprint(np.array([5, 4], dtype=complex))
Output
[5.+0.j 4.+0.j]
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More numpy programs

← All 100 NumPy Programs