借助cmath.sqrt()方法,通過將其傳遞給cmath.sqrt()方法。
用法:cmath.sqrt(value)
返回:Return the square root of any value.
範例1:
在這個例子中,我們可以通過使用cmath.sqrt()方法,我們可以通過將平方根值傳遞給它來獲得平方根的值。
# importing cmath library 
import cmath 
  
# using cmath.sqrt() method 
gfg = cmath.sqrt(4) 
  
print(gfg)輸出:
(2+0j)
範例2:
# importing cmath library 
import cmath 
  
# using cmath.sqrt() method 
gfg = cmath.sqrt(3) 
  
print(gfg)輸出:
(1.7320508075688772+0j)
相關用法
- Python next()用法及代碼示例
 - Python os.dup()用法及代碼示例
 - Python set()用法及代碼示例
 - Python Decimal max()用法及代碼示例
 - Python PIL ImageOps.fit()用法及代碼示例
 - Python os.rmdir()用法及代碼示例
 - Python sympy.det()用法及代碼示例
 - Python Decimal min()用法及代碼示例
 - Python os.readlink()用法及代碼示例
 - Python os.writev()用法及代碼示例
 - Python os.readv()用法及代碼示例
 - Python PIL RankFilter()用法及代碼示例
 - Python os.rename()用法及代碼示例
 - Python os.sendfile()用法及代碼示例
 
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | cmath.sqrt() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
