Phương thức Python cmath.sqrt ()
Thí dụ
Tìm căn bậc hai của một số phức:
#Import cmath Library
import cmath
#Return the square root of a
complex number
print (cmath.sqrt(2 + 3j))
print (cmath.sqrt(15))
Định nghĩa và Cách sử dụng
Phương cmath.sqrt()
thức trả về căn bậc hai của một số phức.
Lưu ý: Số phải lớn hơn hoặc bằng 0.
Cú pháp
cmath.sqrt(x)
Giá trị tham số
Parameter | Description |
---|---|
x | Required. A number to find the square root of. If the number is less than 0, it returns a ValueError. If the value is not a number, it returns a TypeError |
Chi tiết kỹ thuật
Giá trị trả lại: | Một complex giá trị, đại diện cho căn bậc hai của một số phức |
---|---|
Phiên bản Python: | 1,5 |