码迷,mamicode.com
首页 > 编程语言 > 详细

Python3——数学标准库使用

时间:2019-12-26 13:25:05      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:img   htm   math   div   com   floor   字母   margin   集合   

import random
print(random.randint(1,9))  #随机数 每次取出一个 1-9
print(random.choice([a,b,c]))  #随机取出一个字母

# 更多math库函数请参考:https://docs.python.org/3/library/math.html
import math
print(math.pi)   #圆周率
a = 2.51
b = 5.21
print(math.ceil(a))        #对x向上取整 3
print(math.floor(a))       #向下取整  2
# print(math.pow(x,y))       # x的y次方 4.0
print(math.sqrt(4))        # 2的平方根 2.0
aa = [1,2,3]
print(math.fsum(aa))       # 对集合内的元素求和 6.0

技术图片

Python3——数学标准库使用

标签:img   htm   math   div   com   floor   字母   margin   集合   

原文地址:https://www.cnblogs.com/gjh99/p/12101391.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!