首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

Python惯用函数

2012-10-06 
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

热点排行