파이썬에서 반올림,올림,버림,내림 하는 법
파이썬에서 반올림,올림,버림,내림 하는 법 반올림 round(수, 자리수) >>> round(345.345,1)345.3 >>> round(345.345,2)345.35 >>> round(345.345,-1)350.0 >>> round(345.345,-2)300.0 올림 올림은 입력값보다 같거나 큰 정수중 가장 가까운 값을 반환합니다. math 라이브러리의 ceil 메소드를 이용합니다. >>> import math >>> math.ceil(3)3 >>> math.ceil(3.4)4 >>> math.ceil(3.6)4 >>> math.ceil(-3.4)-3 >>> math.ceil(-3.6)-3 >>> math.ceil(-3)-3 버림 버림은 소수점을 그냥 버리는 것입니다. math 라이브러리의 trunc..
2020. 11. 5.