美文网首页
Python学习笔记(2014.10.02)

Python学习笔记(2014.10.02)

作者: 许卫栋 | 来源:发表于2014-10-02 20:01 被阅读10次

math模块(数学函数):

使用math模块

import math
dir(math) 这句可查看所有函数名列表
help(math) 查看具体定义及函数原型

常用的数学函数:
ceil(x) 取顶
floor(x) 取底
fabs(x) 取绝对值
factorial (x) 阶乘
hypot(x,y) sqrt(xx+yy)
pow(x,y) x的y次方
sqrt(x) 开平方
log(x)
log10(x)
trunc(x) 截断取整数部分
isnan (x) 判断是否NaN(not a number)
degree (x) 弧度转角度
radians(x) 角度转弧度

另外该模块定义了两个常量:
DATA
e = 2.718281828459045
pi = 3.141592653589793

相关文章

网友评论

      本文标题:Python学习笔记(2014.10.02)

      本文链接:https://www.haomeiwen.com/subject/binutttx.html