Python Math.copysign() Metoda
Przykład
Zwróć wartość pierwszego parametru i znak drugiego parametru:
#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))
Definicja i użycie
Metoda math.copysign()
zwraca liczbę zmiennoprzecinkową składającą się z wartości pierwszego parametru i znaku (+/-) drugiego parametru.
Składnia
math.copysign(x, y)
Wartości parametrów
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 |
Szczegóły techniczne
Wartość zwrotu: | Wartość float , na którą składa się wartość pierwszego parametru i znak drugiego parametru |
---|---|
Wersja Pythona: | 2,6 |