Python complex() Funksie
Voorbeeld
Skakel die getal 3 en denkbeeldige getal 5 om in 'n komplekse getal:
x = complex(3, 5)
Definisie en gebruik
Die complex()
funksie gee 'n komplekse getal terug deur 'n reële getal en 'n denkbeeldige getal te spesifiseer.
Sintaksis
complex(real, imaginary)
Parameterwaardes
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 voorbeelde
Voorbeeld
Skakel 'n string om in 'n komplekse getal:
x = complex('3+5j')