Método Python math.copysign()
Exemplo
Retorna o valor do primeiro parâmetro e o sinal do 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))
Definição e uso
O math.copysign()
método retorna um float que consiste no valor do primeiro parâmetro e o sinal (+/-) do segundo parâmetro.
Sintaxe
math.copysign(x, y)
Valores de parâmetro
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 |
Detalhes técnicos
Valor de retorno: | Um float valor, que consiste no valor do primeiro parâmetro e no sinal do segundo parâmetro |
---|---|
Versão do Python: | 2.6 |