Python3 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/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))
Nach dem obigen Beispiel Ausgang läuft:
hypot(3, 2) : 3.605551275463989 hypot(-3, 3) : 4.242640687119285 hypot(0, 2) : 2.0