Phương pháp Python math.isqrt ()
Thí dụ
Làm tròn một số căn bậc hai xuống đến số nguyên gần nhất:
# Import math Library
import math
# Print the square
root of different numbers
print (math.sqrt(10))
print (math.sqrt (12))
print (math.sqrt (68))
print (math.sqrt (100))
# Round square root
downward to the nearest integer
print (math.isqrt(10))
print
(math.isqrt (12))
print (math.isqrt (68))
print (math.isqrt (100))
Định nghĩa và Cách sử dụng
Phương math.isqrt()
thức làm tròn một số căn bậc hai xuống đến số nguyên gần nhất.
Lưu ý: Số phải lớn hơn hoặc bằng 0.
Cú pháp
math.isqrt(x)
Giá trị tham số
Parameter | Description |
---|---|
x | Required. The number to round the square root of. If x is negative, it returns a ValueError. If x is not a number, it returns a TypeError |
Chi tiết kỹ thuật
Giá trị trả lại: | Một int giá trị, đại diện cho căn bậc hai của một số, không có số thập phân |
---|---|
Phiên bản Python: | 3.8 |