Latest web development tutorials

função hypot Python3 ()

python3 digitais python3 digitais


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

Depois de executar o exemplo acima saída é:

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

python3 digitais python3 digitais