“模块1:math库的使用”的版本间的差异

来自CloudWiki
跳转至: 导航搜索
函数库的引用
函数库的引用
第8行: 第8行:
 
  >>>print(floor(x))
 
  >>>print(floor(x))
 
  >>>from math import *
 
  >>>from math import *
 +
*对于这一种方式,库中的所有函数可直接使用
  
 
==math库解析==
 
==math库解析==

2018年3月11日 (日) 07:22的版本

函数库的引用

  • 两种方式
  • 第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:天天向上的力量