Python Math hypot() 函数

Python Math hypot() 函数

Python Math hypot() 返回欧几里德范数 sqrt(xx + yy)。

Python Math hypot() 语法

以下是 hypot() 方法的语法:

import math

math.hypot(x, y)

注意:hypot()是不能直接访问的,需要导入 math 模块,然后通过 math 静态对象调用该方法。

Python Math hypot() 参数

  • x : 一个数值。
  • y : 一个数值。

Python Math hypot() 返回值

返回欧几里德范数 sqrt(x*x + y*y)。

Python Math hypot() 示例1

以下展示了使用 hypot() 方法的实例:

#!/usr/bin/python3
import math

print ("hypot(6, 4) : ",  math.hypot(6, 4))
print ("hypot(-6, 6) : ",  math.hypot(-6, 6))
print ("hypot(0, 2) : ",  math.hypot(0, 2))

输出:

Python Math hypot() 函数

Python Math hypot() 示例2

hypot()函数中的错误。

#!/usr/bin/python3
import math

print("hypot(3, 4, 6) : ", math.hypot(3, 4, 6))

输出:

Python Math hypot() 函数


赞(1)
未经允许不得转载:极客笔记 » Python Math hypot() 函数

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址