python函数示例_带Python示例的complex()函数
python函數示例
Python complex()函數 (Python complex() function)
complex() function is a library function in Python, it is used to get the complex number from given a real number or/and an imaginary number (which is an optional part), it accepts either a real number only or read and an imaginary number and returns a complex number.
complex()函數是Python中的一個庫函數,用于從給定的實數或/和虛數(這是可選部分)中獲取復數,它僅接受實數,也可以接受讀數和虛數數字并返回一個復數。
Syntax:
句法:
complex(real [,Imaginary])Parameter(s):
參數:
real – value of a real number
實數 –實數的值
Imaginary – an optional parameter, it's default value is 0.
虛構 –可選參數,默認值為0。
Return value: complex – it returns a complex type of number containing the value in the form of (real + imaginary*j).
返回值: complex –返回復雜的數字類型,其中包含(real +虛數* j)形式的值。
Example:
例:
Input:real = 10img = 20print(complex(real))print(complex(real, img))Output:(10+0j)(10+20j)Python code to get the complex number
Python代碼獲取復數
# python code to demonstrate example # of complex() functionreal = 10 img = 20# complex number by passing real number print(complex(real))# complex number by passing real & img. number print(complex(real, img))# complex number by passing real part as 0 print(complex(0))# complex number by passing real and img. part as 0, 0 print(complex(0,0))# with float values real = 10.23 img = 20.45# complex number by passing real number print(complex(real))# complex number by passing real & img. number print(complex(real, img))Output
輸出量
(10+0j) (10+20j) 0j 0j (10.23+0j) (10.23+20.45j)翻譯自: https://www.includehelp.com/python/complex-function-with-example.aspx
python函數示例
總結
以上是生活随笔為你收集整理的python函数示例_带Python示例的complex()函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 根据类名示例化类_Java L
- 下一篇: Python中的条件语句(if,if .