Python math.isqrt ()วิธี การ
ตัวอย่าง
ปัดเศษจำนวนรากที่สองลงเป็นจำนวนเต็มที่ใกล้เคียงที่สุด:
# 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))
ความหมายและการใช้งาน
วิธี การmath.isqrt()
ปัดเศษจำนวนรากที่สองลงเป็นจำนวนเต็มที่ใกล้เคียงที่สุด
หมายเหตุ:ตัวเลขต้องมากกว่าหรือเท่ากับ 0
ไวยากรณ์
math.isqrt(x)
ค่าพารามิเตอร์
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 |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่า ที่int แทนรากที่สองของตัวเลขโดยไม่มีทศนิยม |
---|---|
เวอร์ชันหลาม: | 3.8 |