小白教程
所有教程
关于
Search
172.70.130.241
172.70.130.241
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Ref math hypot”的源代码
本页内容
上一节:
Ref_math_gcd
下一节:
Ref_math_isclose
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:math.hypot()}}[[Category:python math|32]] = Python math.hypot() 方法 = [[python math|Python math 模块]] Python '''math.hypot()''' 方法返回欧几里得范数。 欧几里得范数是从原点到给定坐标的距离。 欧几里得度量又称为欧几里得距离,指的是欧几里得空间中两点间"普通"(即直线)距离。 在 Python 3.8 之前,此方法用于查找直角三角形的斜边:sqrt(x*x + y*y)。 从 Python 3.8 开始,此方法也用于计算欧几里得范数。 对于 n 维情况,假定传递的坐标类似于 '''(x1, x2, x3, ..., xn)''',从原点开始的欧几里得长度由 sqrt(x1*x1 + x2*x2 +x3*x3 .... xn*xn) 计算。 Python 版本: 3.8 === 语法 === math.hypot() 方法语法如下: <sample title="" desc="" lang="python" hererun="1"> math.hypot(x1, x2, x3, ..., xn) </sample> '''参数说明:''' * '''x1, x2, x3, ..., xn''' -- 必需,表示多个坐标点。 === 返回值 === 一个浮点值,表示 n 个输入到原点的欧几里得距离,或两个输入的直角三角形的斜边 == 以下实例计算直角三角形的斜边: <sample title="" desc="" lang="python" hererun="1"> # 导入 math 包 import math # 设置垂直线和底边 parendicular = 10 base = 5 # 输出直角三角形的斜边 print(math.hypot(parendicular, base)) </sample> 输出结果: <sample title="" desc="" lang="python" hererun="1"> 11.180339887498949 </sample> 以下实例计算给定坐标的欧几里得范数: <sample title="" desc="" lang="python" hererun="1"> # 导入 math 包 import math # 输出给定坐标的欧几里得范数 print(math.hypot(10, 2, 4, 13)) print(math.hypot(4, 7, 8)) print(math.hypot(12, 14)) </sample> 输出结果: <sample title="" desc="" lang="python" hererun="1"> 17.0 11.357816691600547 18.439088914585774 </sample> [[python math|Python math 模块]]
返回至“
Ref math hypot
”。
上一节:
Ref_math_gcd
下一节:
Ref_math_isclose