Python complex() Functie
Voorbeeld
Zet het getal 3 en denkbeeldige getal 5 om in een complex getal:
x = complex(3, 5)
Definitie en gebruik
De complex()
functie retourneert een complex getal door een reëel getal en een denkbeeldig getal op te geven.
Syntaxis
complex(real, imaginary)
Parameterwaarden
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. |
Meer voorbeelden
Voorbeeld
Converteer een string naar een complex getal:
x = complex('3+5j')