Metodo Python Number hypot ()

Descrizione

Metodo numerico Python hypot() restituisce la norma euclidea, sqrt (x * x + y * y).

Sintassi

Di seguito è riportata la sintassi per hypot() metodo -

hypot(x, y)

Note - Questa funzione non è accessibile direttamente, quindi dobbiamo importare il modulo matematico e quindi dobbiamo chiamare questa funzione utilizzando l'oggetto statico matematico.

Parametri

  • x - Deve essere un valore numerico.

  • y - Deve essere un valore numerico.

Valore di ritorno

Questo metodo restituisce la norma euclidea, sqrt (x * x + y * y).

Esempio

L'esempio seguente mostra l'utilizzo del 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)

Quando eseguiamo il programma sopra, produce il seguente risultato:

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