Python math.copysign() Method
ตัวอย่าง
ส่งคืนค่าของพารามิเตอร์ตัวแรกและเครื่องหมายของพารามิเตอร์ตัวที่สอง:
#Import math Library
import math
#Return the value of the first
parameter and the sign of the second parameter
print(math.copysign(4, -1))
print(math.copysign(-8, 97.21))
print(math.copysign(-43, -76))
ความหมายและการใช้งาน
เมธอดส่งคืน ค่าmath.copysign()
ทศนิยมซึ่งประกอบด้วยค่าของพารามิเตอร์ตัวแรกและเครื่องหมาย (+/-) ของพารามิเตอร์ตัวที่สอง
ไวยากรณ์
math.copysign(x, y)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
x | Required. A number. The return will have the value of this parameter |
y | Required. A number. The return will have the sign (+/-) of this parameter |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่าfloat ซึ่งประกอบด้วยค่าของพารามิเตอร์ตัวแรก และเครื่องหมายของพารามิเตอร์ตัวที่สอง |
---|---|
เวอร์ชันหลาม: | 2.6 |