Python| cmath.sqrt() 方法
在cmath.sqrt()
方法的帮助下,我们可以通过将平方根传递给cmath.sqrt()
方法来找到任意数字的值。
Syntax : cmath.sqrt(value)
Return : 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)