728x90
# 반올림
round() 함수 사용하기
round(1.6) # 2 출력
round(1.789, 2) # 1.79 출력
round(11.789, -1) # 10 출력
# 내림
import math 후 math.floor() 사용하기
import math
math.floor(3.1415) # 3 출력
# 올림
import math 후 math.ceil() 사용하기
import math
math.ceil(3.1415) # 4 출력
How do you round UP a number?
How does one round a number UP in Python? I tried round(number) but it rounds the number down. Example: round(2.3) = 2.0 and not 3, as I would like. The I tried int(number + .5) but it round the ...
stackoverflow.com
'Algorithm > Python' 카테고리의 다른 글
[Pandas] (0) | 2022.10.28 |
---|---|
[파이썬] - index 함수 (0) | 2022.08.31 |
[파이썬] - 리스트 랜덤하게 섞기, 순서 섞기 (0) | 2022.08.26 |
[파이썬] - for문으로 짝수 합 구하기 (0) | 2022.08.26 |
[파이썬] 리스트 list - 리스트 추가 / 랜덤한 항목 출력하기 (0) | 2022.08.26 |