Python math.copysign() Metodo
Esempio
Restituisce il valore del primo parametro e il segno del secondo parametro:
#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))
Definizione e utilizzo
Il math.copysign()
metodo restituisce un float costituito dal valore del primo parametro e dal segno (+/-) del secondo parametro.
Sintassi
math.copysign(x, y)
Valori dei parametri
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 |
Dettagli tecnici
Valore di ritorno: | Un float valore, che consiste nel valore del primo parametro e nel segno del secondo parametro |
---|---|
Versione Python: | 2.6 |