Python math.sqrt ()วิธี การ
ตัวอย่าง
ค้นหารากที่สองของตัวเลขต่างๆ:
# Import math Library
import math
# Return the square root of
different numbers
print (math.sqrt(9))
print (math.sqrt(25))
print
(math.sqrt(16))
ความหมายและการใช้งาน
วิธี การmath.sqrt()
ส่งคืนรากที่สองของตัวเลข
หมายเหตุ:ตัวเลขต้องมากกว่าหรือเท่ากับ 0
ไวยากรณ์
math.sqrt(x)
ค่าพารามิเตอร์
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 |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่า ที่float แทนรากที่สองของตัวเลข |
---|---|
เวอร์ชันหลาม: | 1.4 |