Método Python math.copysign()
Ejemplo
Devuelve el valor del primer parámetro y el signo del segundo parámetro:
#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))
Definición y uso
El math.copysign()
método devuelve un flotante que consiste en el valor del primer parámetro y el signo (+/-) del segundo parámetro.
Sintaxis
math.copysign(x, y)
Valores paramétricos
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 |
Detalles técnicos
Valor devuelto: | Un float valor, que consta del valor del primer parámetro y el signo del segundo parámetro |
---|---|
Versión de Python: | 2.6 |