Python math.copysign() Metode
Contoh
Kembalikan nilai parameter pertama dan tanda parameter kedua:
#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))
Definisi dan Penggunaan
Metode math.copysign()
mengembalikan float yang terdiri dari nilai parameter pertama dan tanda(+/-) dari parameter kedua.
Sintaksis
math.copysign(x, y)
Nilai Parameter
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 |
Detail Teknis
Nilai Kembali: | Nilai float , yang terdiri dari nilai parameter pertama, dan tanda parameter kedua |
---|---|
Versi Python: | 2.6 |