Kompleks Python () Fungsi
Contoh
Ubahlah bilangan 3 dan bilangan imajiner 5 menjadi bilangan kompleks:
x = complex(3, 5)
Definisi dan Penggunaan
Fungsi complex()
mengembalikan bilangan kompleks dengan menentukan bilangan real dan bilangan imajiner.
Sintaksis
complex(real, imaginary)
Nilai Parameter
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. |
Lebih Banyak Contoh
Contoh
Mengubah string menjadi bilangan kompleks:
x = complex('3+5j')