Python 基礎(chǔ)教程
hypot() 返回歐幾里德范數(shù) sqrt(x*x + y*y)。
以下是 hypot() 方法的語(yǔ)法:
import math math.hypot(x, y)
注意:hypot()是不能直接訪問(wèn)的,需要導(dǎo)入 math 模塊,然后通過(guò) math 靜態(tài)對(duì)象調(diào)用該方法。
返回歐幾里德范數(shù) sqrt(x*x + y*y)。
以下展示了使用 hypot() 方法的實(shí)例:
#!/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)
以上實(shí)例運(yùn)行后輸出結(jié)果為:
hypot(3, 2) : 3.60555127546 hypot(-3, 3) : 4.24264068712 hypot(0, 2) : 2.0其他擴(kuò)展