دالة مجمع بايثون ()
مثال
حول الرقم 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')