Python
[파이썬 Python] 숫자 처리 함수
microsaurs
2022. 12. 4. 23:38
<숫자 처리 함수>
abs = 절대값 함수
pow = 제곱 함수
max = 최대값
min = 최소값
round = 반올림 함수
print(abs(-5)) # 5
print(pow(4,2)) # 4^2 = 16
print(max(5,12)) # 12
print(min(5,12)) # 5
print(round(3.14) # 3 기본적으로 정수형만 남김
print(round(4.99) # 5
파이썬에서는 math 라는 라이브러리를 사용할 수 있습니다.
from math import *
print(floor(4.99)) # 내림 4
print(ceil(3.14)) # 올림 4
print(sqrt(16)) # 제곱근 4