Python Hypot()返回欧几里德范数,sqrt(x*x+y*y)。
hypot(x, y) - 语法
hypot(x, y)
x - 这必须是一个数值。
y - 这必须是一个数值。
hypot(x, y) - 返回值
此方法返回欧几里德范数,sqrt(x*x+y*y)。
hypot(x, y) - 示例
以下示例显示Hypt()方法的用法。
#!/usr/bin/python import mathprint "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