[Python]소수점,올림,반올림


[Python]소수점,올림,반올림

반올림 round >>> n = 7/15 >>> n 0.4666666666666667 >>> round(n,2) 0.47 >>> round(n,4) 0.4667 >>> round(n) 0 >>> type(round(n)) math.ceil(i) : 올림 math.floor(i) : 내림 math.trunc(i) : 버림 import math >>> math.ceil(12.2) 13 >>> math.ceil(12.6) 13 >>> math.floor(12.2) 12 >>> math.floor(12.6) 12 >>> math.trunc(12.2) 12 >>> math.trunc(12.6) 12


원문링크 : [Python]소수점,올림,반올림