Función compleja de Python ()
Ejemplo
Convierta el número 3 y el número imaginario 5 en un número complejo:
x = complex(3, 5)
Definición y uso
La complex()
función devuelve un número complejo especificando un número real y un número imaginario.
Sintaxis
complex(real, imaginary)
Valores paramétricos
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. |
Más ejemplos
Ejemplo
Convierte una cadena en un número complejo:
x = complex('3+5j')