Latest web development tutorials

Python hypot function ()

figure Python figure Python


descrizione

hypot () Restituisce il sqrt norma euclidea (x * x + y * y).


grammatica

Quanto segue è il metodo sintassi hypot ():

import math

math.hypot(x, y)

Nota: hypot () non è direttamente accessibile, è necessario importare il modulo per la matematica, e quindi chiamare il metodo con oggetti statici matematica.


parametri

  • x - un valore.
  • y - un valore.

Valore di ritorno

Torna sqrt norma euclidea (x * x + y * y).


Esempi

Quanto segue mostra un esempio di utilizzo il metodo hypot ():

#!/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)

Dopo aver eseguito l'output sopra esempio è:

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

figure Python figure Python