python教程

python数学函数公式

python数学函数公式

分类:python教程 大小:未知 热度:45 点评:0
发布:
支持:
关键词:

应用介绍

python数学函数公式,math 模块为浮点运算提供了对底层 C 函数库的访问:

>>> import math
>>> math.cos(math.pi / 4.0)
0.70710678118654757
>>> math.log(1024, 2)
10.0

random 提供了生成随机数的工具:

>>> import random
>>> random.choice(['apple', 'pear', 'banana'])
'apple'
>>> random.sample(xrange(100), 10)   # sampling without replacement
[30, 83, 16, 4, 8, 81, 41, 50, 18, 33]
>>> random.random()    # random float
0.17970987693706186
>>> random.randrange(6)    # random integer chosen from range(6)
4

相关应用

最新评论

我要评论