Python/Examples
Python | Examples | Math functions (buillt-in), 버림, 반올림, 내림, 올림
xxoul
2016. 3. 7. 18:06
- Python Basic Math Functions
- Built-ins
##
# -*- coding: utf-8 -*-
# All numbers.Real types (int, long, and float) also include the following operations:
print '-'*10, 'math.trunc(x), round(x), math.floor(x), math.ceil(x)'
import math
x = 2.4
y = 2.6
print math.trunc(x), math.trunc(y) # 버림
print round(x), round(y) # 반올림
print math.floor(x), math.floor(y) # 내림
print math.ceil(x), math.ceil(y) # 올림
##