Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python hypot() function

Python hypot() function

Python Numbers Python Numbers


Description

hypot() Returns the Euclidean norm sqrt(xx + yy).


Syntax

The syntax of the hypot() method is as follows:



import math



math.hypot(x, y)

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


Parameters


Return Value

Returns the Euclidean norm sqrt(xx + yy).


Example

The following shows examples of using the 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)

Running the example above produces:



hypot(3, 2) :  3.60555127546

hypot(-3, 3) :  4.24264068712

hypot(0, 2) :  2.0

Python Numbers Python Numbers