Python Hypot()返回欧几里德范数,sqrt(x*x+y*y)。
hypot(x, y)
x - 这必须是一个数值。
y - 这必须是一个数值。
此方法返回欧几里德范数,sqrt(x*x+y*y)。
以下示例显示Hypt()方法的用法。
#!/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)
当无涯教程运行上面的程序时,它产生以下结果-
hypot(3, 2) : 3.60555127546 hypot(-3, 3) : 4.24264068712 hypot(0, 2) : 2.0
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)