Fonction Python complexe()
Exemple
Convertissez le nombre 3 et le nombre imaginaire 5 en un nombre complexe :
x = complex(3, 5)
Définition et utilisation
La complex()
fonction renvoie un nombre complexe en spécifiant un nombre réel et un nombre imaginaire.
Syntaxe
complex(real, imaginary)
Valeurs des paramètres
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. |
Plus d'exemples
Exemple
Convertissez une chaîne en un nombre complexe :
x = complex('3+5j')