python | 数据类型 | 数值
2018-01-08 00:01
74 查看
# encoding: utf-8 import math import random # 绝对值 print(abs(-32)) # 最大值 print(max(13, 32, 453, 54, 43, 43, 334)) # 最小值 print(min(13, 32, 453, 54, 43, 43, 334)) # 四舍五入 print(round(3.14743, 2)) # 次方 print(pow(2, 4)) # 向上取整 print(math.ceil(3.1)) # 向下取整 print(math.floor(3.9)) # 求开方 print(math.sqrt(9)) # 求对数 print(math.log(10000, 100)) # 随机函数 # 默认范围为[0,1)内的随机小数 print(random.random()) # 范围为序列中的数 print(random.choice(range(1, 101))) seq = [1, 2, 3, 4, 5, 6, 7] print(random.choice(seq)) # 范围为[x, y]内的随机小数 print(random.uniform(1, 3)) # 范围为[x, y]内的随机整数 print(random.randint(1, 3)) # 范围为[x, y)内的随机整数,可设置步长 print(random.randrange(1, 13, 2)) # 三角函数 # 求sin(30) print(math.sin(math.pi * 1 / 6)) # 角度转弧度 print(math.sin(math.radians(30)))
相关文章推荐
- 04_Python的数据类型1数值和字符串_Python编程之路
- python 学习笔记(2)数据类型1 (bool型, 数值类型,lists列表类型)
- 【C014】Python数据类型 - 数值类型
- Python数据类型——数值类型
- python:如何将txt文件中的数值数据读入到list中,且在list中存在的格式为float类型或者其他数值类型
- python数值数据类型
- Python第三天 序列 5种数据类型 数值 字符串 列表 元组 字典
- python 数据类型之数值型
- 04_Python的数据类型1数值和字符串_Python编程之路
- Python中的变量、数据类型(数值、列表)操作实例
- 04_Python的数据类型1数值和字符串_Python编程之路
- python常用数据类型操作-数值篇
- python数据类型之数值类型
- js数值计算时使用parseInt进行数据类型转换(jquery)
- [Dive into Python:第三章]内置数据类型
- Python3 基本数据类型
- Python学习02:基本数据类型
- 数值数据类型
- Python语法基础(一):变量和数据类型
- Python基本数据类型(三)