How to use the copysign(x, y) function (x copied the sign of y) in Python

1 Answer

0 votes
import math

print(math.copysign(0.3, -5))
print(math.copysign(-21, 4))
print(math.copysign(-65, -99))
print("\n")
print(math.copysign(0.3, 5))
print(math.copysign(21, 4))
print(math.copysign(-65, 99))


'''
run:

-0.3
21.0
-65.0


0.3
21.0
65.0

'''

 



answered Oct 11, 2017 by avibootz
...