Função Python complex()
Exemplo
Converta o número 3 e o número imaginário 5 em um número complexo:
x = complex(3, 5)
Definição e uso
A complex()
função retorna um número complexo especificando um número real e um número imaginário.
Sintaxe
complex(real, imaginary)
Valores de parâmetro
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. |
Mais exemplos
Exemplo
Converter uma string em um número complexo:
x = complex('3+5j')