| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
- # 可使用内置模块 statistics 计算由数字组成的可迭代对象的均值、中间值和众数(mode)
 
 - # 可使用内置模块 keyword 检查字符串是不是 Python关键字
 
 - import math
 
 - import statistics as s
 
 - import keyword
 
  
- print(math.pi)
 
 - print(math.pow(2,3))  # 等价于2**3
 
 - nums = [1, 5, 33, 12, 46, 33, 2]
 
 - # 均值
 
 - print(s.mean(nums))
 
 - print('%.4f' % s.mean(nums))
 
 - # 中间值
 
 - print(s.median(nums))
 
 - # 众数
 
 - print(s.mode(nums))
 
 - print(keyword.iskeyword('for'))  # True
 
 - print(keyword.iskeyword('football'))  # False
 
  复制代码 |   
 
 
 
 |