Python hypot function ()
opis
hypot () Zwraca euklidesową sqrt (x * norma x + y * y).
gramatyka
Poniżej znajduje się Składnia metody hypot ():
import math math.hypot(x, y)
Uwaga: hypot () nie jest bezpośrednio dostępna, należy zaimportować moduł matematyczny, a następnie wywołać metodę, za pomocą statycznych obiektów matematycznych.
parametry
- x - wartość.
- y - wartość.
Wartość zwracana
Powrót normą euklidesową sqrt (x * x + y * y).
Przykłady
Poniżej przedstawiono przykład zastosowania metody 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)
Po uruchomieniu wyjście Powyższy przykład jest:
hypot(3, 2) : 3.60555127546 hypot(-3, 3) : 4.24264068712 hypot(0, 2) : 2.0