#Python(033)函數round()的應用
'''
rounf():處理整數位數左邊為奇數則使用四捨五入,
如果是偶數則使用五捨六入。
處理小數時"5"以下捨去"51"以上時進位,
偶數則四捨五入。
第二個參數代表到小數第幾位。
'''
i = 1.5
j = 1.115
k = 1.1151
m = 2.5
n = 2.6
o = 2.224
p = 2.225
print('round(1.5)=')
print(round(i))
print('round(1.115)=')
print(round(j,2))
print('round(1.1151)=')
print(round(k,2))
print('round(2.5)=')
print(round(m))
print('round(2.6)=')
print(round(n))
print('round(2.224)=')
print(round(o,2))
print('round(2.225)=')
print(round(p,2))
print('直接輸入數字:')
print(round(2.115,2))
print('函數round()計算完後i的值為:')
print(i)
'''
函數round()計算完的值並不會改變
'''
結果為:
文章標籤
全站熱搜