Python math.remainder()วิธี การ
ตัวอย่าง
คืนค่าส่วนที่เหลือของ x เทียบกับ y:
# Import math Library
import math
# Return the remainder of x/y
print (math.remainder(9, 2))
print (math.remainder(9,
3))
print
(math.remainder(18, 4))
ความหมายและการใช้งาน
วิธี นี้math.remainder()
จะคืนค่าส่วนที่เหลือของ x เทียบกับ y
ไวยากรณ์
math.remainder(x, y)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
x | Required. The number you want to divide. |
y | Required. The number you want to divide with. It must be a non-zero number, or a ValueError occurs. |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่า ที่float แสดงถึงส่วนที่เหลือ |
---|---|
เวอร์ชันหลาม: | 3.7 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
คืนค่าส่วนที่เหลือของ x/y:
print (math.remainder(23.5, 5))
print
(math.remainder(23, 5.5))
print (math.remainder(12.5, 2.5))
print
(math.remainder(12, 2))