Комплекс Python () Функция
Пример
Преобразуйте число 3 и мнимое число 5 в комплексное число:
x = complex(3, 5)
Определение и использование
Функция complex()
возвращает комплексное число, указав действительное число и мнимое число.
Синтаксис
complex(real, imaginary)
Значения параметров
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. |
Дополнительные примеры
Пример
Преобразование строки в комплексное число:
x = complex('3+5j')