Python3 hypot() Function

Python3 数字Python3 Numbers


Description

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


Syntax

The following is the syntax of the hypot() method:

import math

math.hypot(x, y)

Note:hypot() cannot be accessed directly; you need to import the math module and then call the method through the math static object.


Parameters

  • x -- A numeric value.
  • y -- A numeric value.

Return Value

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


Example

The following example demonstrates the use of the 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, the output result is:

hypot(3, 2) :  3.605551275463989
hypot(-3, 3) :  4.242640687119285
hypot(0, 2) :  2.0

Python3 数字Python3 Numbers

Other Extensions