Python hypot function

Python hypot() function calculates the hypotenuse of a right triangle. It's a method of math module. hypot(x,y): x,y are the two sides of the right triangle, hypotenuse = √x * x + y * y.

>>> import math
>>> math.hypot(3,4)
5.0
The negative sign will be neglected:
>>> import math
>>> math.hypot(-3,4)
5.0
>>> math.hypot(0,4)
4.0


















endmemo.com © 2024  | Terms of Use | Privacy | Home