Phương thức toán học Python.copysign ()
Thí dụ
Trả về giá trị của tham số đầu tiên và dấu của tham số thứ hai:
#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))
Định nghĩa và Cách sử dụng
Phương math.copysign()
thức trả về một số float bao gồm giá trị của tham số đầu tiên và dấu (+/-) của tham số thứ hai.
Cú pháp
math.copysign(x, y)
Giá trị tham số
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 |
Chi tiết kỹ thuật
Giá trị trả lại: | Một float giá trị, bao gồm giá trị của tham số đầu tiên và dấu hiệu của tham số thứ hai |
---|---|
Phiên bản Python: | 2,6 |