Latest web development tutorials

fonction Python hypot ()

chiffres Python chiffres Python


description

hypot () Renvoie la sqrt norme euclidienne (x * x + y * y).


grammaire

Ce qui suit est la syntaxe de méthode hypot ():

import math

math.hypot(x, y)

Note: hypot () ne sont pas directement accessibles, vous devez importer le module de mathématiques, puis appeler la méthode par mathématiques objets statiques.


Paramètres

  • x - une valeur.
  • y - une valeur.

Valeur de retour

Retour norme euclidienne sqrt (x * x + y * y).


Exemples

Le tableau suivant montre un exemple d'utilisation du procédé 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)

Après avoir exécuté l'exemple ci-dessus est sortie:

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

chiffres Python chiffres Python