Latest web development tutorials

Python hypot () function

Python figures Python figures


description

hypot () Returns the Euclidean norm sqrt (x * x + y * y).


grammar

The following is the syntax hypot () method:

import math

math.hypot(x, y)

Note: hypot () is not directly accessible, you need to import math module, and then call the method by math static objects.


parameter

  • x - a value.
  • y - a value.

return value

Back Euclidean norm sqrt (x * x + y * y).


Examples

The following shows an example of using hypot () method:

#!/usr/bin/python
import math

print "hypot(3, 2) : ",  math.hypot(3, 2)
print "hypot(-3, 3) : ",  math.hypot(-3, 3)
print "hypot(0, 2) : ",  math.hypot(0, 2)

After running the above example output is:

hypot(3, 2) :  3.60555127546
hypot(-3, 3) :  4.24264068712
hypot(0, 2) :  2.0

Python figures Python figures