Python3 hypot() 関数

Python3 数字Python3 数値


説明

hypot()ユークリッドノルム sqrt(x*x + y*y) を返します。


構文

以下は hypot() メソッドの構文です:

import math

math.hypot(x, y)

注意:hypot() は直接アクセスできません。math モジュールをインポートし、math 静的オブジェクトを介してこのメソッドを呼び出す必要があります。


引数

  • x -- 数値。
  • y -- 数値。

戻り値

ユークリッドノルム sqrt(x*x + y*y) を返します。


例

以下は hypot() メソッドを使用した例です:

#!/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))

上記の例を実行した後の出力結果は次のとおりです:

hypot(3, 2) :  3.605551275463989
hypot(-3, 3) :  4.242640687119285
hypot(0, 2) :  2.0

Python3 数字Python3 数値

その他の拡張