內建函式

round

會自動四捨五入到指定位數。

語法

round(數字,小數點位數)
1
print(round(55.19, 1))
55.2

abs 絕對值

絕對值abs(參數),參數若為負數,執行結果會變正數。

1
2
print(abs(-100))
print(abs(-11.5))
100
11.5

results matching ""

    No results matching ""