On this page
  1. complex
  2. Import & Availability
  3. Overview & Signature
  4. Common Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

complex

Prev: compile | Up: __builtins__ | Next: copyright
Rel: bool, int, float, str, bytes
Ref: docs.python.org — complex
Tags: #public #python3 #builtins


Import & Availability

# Built-in (available globally without import)
from builtins import complex

Overview & Signature

complex(real=0, imag=0)

Create a complex number from a string or numbers.

Common Methods & Attributes

Usage

z = complex(3, 4)
assert z == (3 + 4j) and z.real == 3.0 and z.imag == 4.0 and abs(z) == 5.0
assert z.conjugate() == (3 - 4j)

Gotchas

REPL Inspect

help(complex)

Linked from

Related notes