模块1:math库的使用
来自CloudWiki
函数库的引用
- 两种方式
- 第1种:
>>>import math >>>math.ceil(10,2)
- 第2种:
>>>from math import floor >>>print(floor(x)) >>>from math import *
- 对于这一种方式,库中的所有函数可直接使用
math库解析
数学常数
math.pi math.e math.inf math.nan
数值表示函数
math.fabs(x) math.fmod(x,y):求余数 math.fsum([x,y,...]) math.ceil(x) math.floor(x) math.factorial(x) math.gcd(a,b)
幂对数函数
math.pow(x,y) math.exp(x)
三角运算函数
math.degree(x) math.radians(x) math.sin(x) math.cos(x) math.tan(x)
=高等特殊函数
下一节 实例3:天天向上的力量