Latest web development tutorials

função Python hypot ()

figuras Python figuras Python


descrição

hypot () Retorna o sqrt norma euclidiana (x * x + y * y).


gramática

O seguinte é o método sintaxe hypot ():

import math

math.hypot(x, y)

Nota: hypot () não é directamente acessível, você precisa importar módulo de matemática, e, em seguida, chamar o método por objetos estáticos matemática.


parâmetros

  • x - um valor.
  • y - um valor.

Valor de retorno

Voltar sqrt norma euclidiana (x * x + y * y).


Exemplos

O seguinte mostra um exemplo do uso de 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)

Depois de executar o exemplo acima saída é:

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

figuras Python figuras Python