Python- complex()- Funktion
Beispiel
Wandle die Zahl 3 und die imaginäre Zahl 5 in eine komplexe Zahl um:
x = complex(3, 5)
Definition und Verwendung
Die complex()
Funktion gibt eine komplexe Zahl zurück, indem sie eine reelle Zahl und eine imaginäre Zahl angibt.
Syntax
complex(real, imaginary)
Parameterwerte
Parameter | Description |
---|---|
real | Required. A number representing the real part of the complex number. Default 0. The real number can also be a String, like this '3+5j', when this is the case, the second parameter should be omitted. |
imaginary | Optional. A number representing the imaginary part of the complex number. Default 0. |
Mehr Beispiele
Beispiel
Konvertieren Sie eine Zeichenfolge in eine komplexe Zahl:
x = complex('3+5j')