Python math function | copysign()
math.copysign() is a function exists in Standard math Library of Python. This function returns a float value consisting of magnitude from parameter x and the sign (+ve or -ve) from parameter y.
Syntax : math.copysign(x, y)
Parameters :
x : Integer value to be converted
y : Integer whose sign is required
Returns : float value consisting of magnitude from parameter x and the sign from parameter y.
Code #1:
# Python code to demonstrate copy.sign() function import math def func(): a = 5 b = -7 # implementation of copysign c = math.copysign(a, b) return c print (func()) |
Output :
-5.0
Code #2:
# Python code to demonstrate copy.sign() function import math def func(): a = 10 b = 10 # implementation of copysign c = math.copysign(a, b) return c print (func()) |
Output :
10
Recommended Posts:
- Python | math.copysign() function
- numpy.copysign() in Python
- Python | math.gcd() function
- Python | math.tan() function
- Python | math.sin() function
- Python | math.cos() function
- Python | math.fabs() function
- Python | math.floor() function
- Python | math.ceil() function
- Python | math.factorial() function
- Python math function | sqrt()
- Python math function | modf()
- Python math function | hypot()
- Python math library | gamma() function
- Python math library | exp() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




