#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()計算完的值並不會改變
'''
結果為:

image

 

 

 

arrow
arrow
    創作者介紹
    創作者 愛學習 的頭像
    愛學習

    愛學習

    愛學習 發表在 痞客邦 留言(0) 人氣()