python3函式語法 Python3

2021-10-11 09:50:10 字數 865 閱讀 4560

python3 degrees() 函式

描述degrees() 將弧度轉換為角度。

語法以下是 degrees() 方法的語法:

import math

math.degrees(x)

注意:degrees()是不能直接訪問的,需要匯入 math 模組,然後通過 math 靜態物件呼叫該方法。

引數x -- 乙個數值。

返回值返回乙個角度值。

例項以下展示了使用 degrees() 方法的例項:

#!/usr/bin/python3

import math

print ("degrees(3) : ", math.degrees(3))

print ("degrees(-3) : ", math.degrees(-3))

print ("degrees(0) : ", math.degrees(0))

print ("degrees(math.pi) : ", math.degrees(math.pi))

print ("degrees(math.pi/2) : ", math.degrees(math.pi/2))

print ("degrees(math.pi/4) : ", math.degrees(math.pi/4))

以上例項執行後輸出結果為:

degrees(3) : 171.88733853924697

degrees(-3) : -171.88733853924697

degrees(0) : 0.0

degrees(math.pi) : 180.0

degrees(math.pi/2) : 90.0

degrees(math.pi/4) : 45.0

Python 常用函式,語法

這裡記錄一些我用python深度學習的七七八八常用函式或者小技巧啥啥的吧 畢竟好記性不如爛筆頭 嗯 會再更噠 1.strip string1.strip string2 一句話來說就是去除字串string1裡面包含的字串行string2 str 00000003210runoob0123000000...

python 函式語法 Python中的函式語法

函式是一段組織好的,可重複使用的,用來實現單一,或相關聯功能的 段。乙個較大的程式通常會分割成若干子程式,每乙個子程式完成乙個特定的功能,這些子程式通常來說就是功能 在乙個專案中,很多功能會被反覆使用,那麼就可以將某段 封裝成函式,當我們要使用的時候直接呼叫即可 函式的本質就是一段有特定功能 可以重...

python 函式語法 python函式的基本語法

函式 一次定義,多次呼叫,函式可以變相看成變數 函式的階段 1.定義階段 2呼叫階段 形參和實參 定義階段的引數叫形參,呼叫階段的引數叫實參 函式的幾種基本用法 多變數 def test name,age print 在下 s,今年 s,請問有何貴幹!name,age a test 趙日天 18 在...