Phương thức toán học Python.sqrt ()
Thí dụ
Tìm căn bậc hai của các số khác nhau:
# Import math Library
import math
# Return the square root of
different numbers
print (math.sqrt(9))
print (math.sqrt(25))
print
(math.sqrt(16))
Định nghĩa và Cách sử dụng
Phương math.sqrt()
thức trả về căn bậc hai của một số.
Lưu ý: Số phải lớn hơn hoặc bằng 0.
Cú pháp
math.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 float giá trị, đại diện cho căn bậc hai của một số |
---|---|
Phiên bản Python: | 1,4 |