日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python函数示例_带Python示例的complex()函数

發布時間:2025/3/11 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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()函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。