Python hypot () Funktion
Beschreibung
hypot () Gibt die euklidische Norm sqrt (x * x + y * y).
Grammatik
Im Folgenden ist die Syntax hypot () -Methode:
import math math.hypot(x, y)
Hinweis: hypot () nicht direkt zugänglich ist, müssen Sie Mathematikmodul zu importieren, und dann rufen Sie die Methode durch mathematische statische Objekte.
Parameter
- x - ein Wert.
- y - ein Wert.
Rückgabewert
Zurück euklidische Norm sqrt (x * x + y * y).
Beispiele
Nachfolgend ein Beispiel für die Verwendung hypot () Methode:
#!/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)
Nach dem obigen Beispiel Ausgang läuft:
hypot(3, 2) : 3.60555127546 hypot(-3, 3) : 4.24264068712 hypot(0, 2) : 2.0