Python Función hypot()

Python 数字Números de Python


Descripción

hypot()Devuelve la norma euclidiana sqrt(x*x + y*y).


Sintaxis

La siguiente es la sintaxis del método hypot():

import math

math.hypot(x, y)

Nota:hypot() no se puede acceder directamente; necesita importar el módulo math y luego llamar a este método a través del objeto estático math.


Parámetros

  • x -- un valor numérico.
  • y -- un valor numérico.

Valor de retorno

Devuelve la norma euclidiana sqrt(x*x + y*y).


Ejemplo

A continuación se muestra un ejemplo del uso del método 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)

Después de ejecutar el ejemplo anterior, el resultado de salida es:

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

Python 数字Números de Python

Otras extensiones