A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python-math-function-copysign/ below:

Python math function | copysign()

Python math function | copysign()

Last Updated : 14 Feb, 2023

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.

Time Complexity: O(1)

Auxiliary Space: O(1)

Code #1: 

Python3
# 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: 

Python3
# 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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4