Python hypot()-Funktion
Beschreibung
hypot()Gibt die euklidische Norm zurück, sqrt(x*x + y*y).
Syntax
Das Folgende ist die Syntax für die hypot()-Methode:
import math math.hypot(x, y)
Hinweis:hypot() ist nicht direkt zugänglich; Sie müssen das math-Modul importieren und dann diese Methode über das statische math-Objekt aufrufen.
Parameters
- x -- Ein numerischer Wert.
- y -- Ein numerischer Wert.
Rückgabewert
Gibt die euklidische Norm sqrt(x*x + y*y) zurück.
Beispiel
Das folgende Beispiel zeigt die Verwendung der 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)
Die Ausgabe des obigen Beispiels ist:
hypot(3, 2) : 3.60555127546 hypot(-3, 3) : 4.24264068712 hypot(0, 2) : 2.0Andere Erweiterungen
Zahlen in Python