Latest web development tutorials

Python3 hypot () function

Python3 digital Python3 digital


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/python3
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.605551275463989
hypot(-3, 3) :  4.242640687119285
hypot(0, 2) :  2.0

Python3 digital Python3 digital