Python中的hypot()方法使用簡介
更新時間:2015年05月18日 09:03:33 投稿:goldensun
這篇文章主要介紹了Python中的hypot()方法使用簡介,是Python入門所需掌握的基礎知識,需要的朋友可以參考下
hypot()方法返回的歐幾里德范數 sqrt(x*x + y*y).
語法
以下是hypot()方法的語法:
hypot(x, y)
注意:此函數是無法直接訪問的,所以我們需要導入math模塊,然后需要用math的靜態(tài)對象來調用這個函數
參數
- x -- 這必須是一個數值
- y -- 此方法返回歐幾里德范數 sqrt(x*x + y*y)
返回值
此方法返回歐幾里德范數 sqrt(x*x + y*y)
例子
下面的例子顯示 hypot()方法的使用。
#!/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
相關文章
django模型類中,null=True,blank=True用法說明
這篇文章主要介紹了django模型類中,null=True,blank=True用法說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07python3.6連接MySQL和表的創(chuàng)建與刪除實例代碼
這篇文章主要介紹了python3.6連接MySQL和表的創(chuàng)建與刪除實例代碼,具有一定借鑒價值,需要的朋友可以參考下2017-12-12