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

你可能感兴趣的:(python)