广州北大青鸟计算机职业培训学校
互联网技术培训、软件技术培训、大数据培训、云计算培训、数据分析培训信息网
当前位置:网站首页 > 软件教程 > Python技术 > 正文

Python3的math模块_惠州计算机Python软件开发

作者:黄君发布时间:2021-01-04分类:Python技术浏览:1310


导读:math模块为浮点运算提供了对底层C函数库的访问:

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

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

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

>>> import random
>>> random.choice(['apple', 'pear', 'banana'])
'apple'
>>> random.sample(range(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


标签:惠州计算机软件培训惠州计算件软件开发惠州计算机软件基础惠州计算机Python软件开发惠州Python培训


Python技术排行
标签列表
网站分类
文章归档
最近发表