- 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) # 올림
##
'Python > Examples' 카테고리의 다른 글
Book | Python Cookbook (0) | 2016.10.31 |
---|---|
Python | Examples | PYTHONPATH 추가하기 (0) | 2016.03.08 |
Python | Examples | 이미지 파일 binary 로 read 후 web browser 에서 data 받아서 보여주기 (0) | 2016.03.03 |
Python | Examples | Python code 에서 bash 명령 실행, command 실행 (0) | 2016.03.03 |
Python | Examples | dictionary 에서 key 값만 얻기 (0) | 2016.03.02 |