Latest web development tutorials

hypot python3 function ()

digitale python3 digitale python3


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

Dopo aver eseguito l'output sopra esempio è:

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

digitale python3 digitale python3