Python惯用函数

Python常用函数input(x:)提示输入raw_input(x:)pow(2,3)2的3次方abs(-10)-10的绝对值round(1.0/2)1.0/

Python常用函数
input("x:")             提示输入
raw_input("x:")
pow(2,3)                2的3次方
abs(-10)                -10的绝对值
round(1.0/2)            1.0/2的四舍五入

>>> import math>>> math.floor(32.9)     # 取最接近,但小于的整数32.0>>> math.ceil(32.4)      # 和floor相反33.0>>> from math import sqrt>>> sqrt(9)3.0>>> import cmath          # complex math, 复数>>> cmath.sqrt(-1)1j