第5节--python数据类型--numeric
来源:互联网 发布:js 获取日期的年月日 编辑:程序博客网 时间:2024/06/14 21:24
1、python数据类型
- numerics, sequences, mappings, classes, instances, exceptions
- Numeric Types: int (包含boolean), float, complex
- int: unlimited length; float: 实现用double in C, 可用 sys.float_info查看
complex: real(实部) & imaginary(虚部),用z.real 和 z.imag来取两部分
具体运算以及法则参见:
https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex
2、例子
import sysa = 3b = 4c = 5.66d = 8.0e = complex(c,d)f = complex(float(a),float(b))# f = complex(a,b)print("a is type: ",type(a))print("c is type: ",type(c))print("e is type: ",type(e))print(a+b)print(d/c)print(b/a)print(b//a)print(e)print(e+f)print ("e's real part is: " , e.real)print ("e's imaginary part is: " , e.imag)print(sys.float_info)
运行结果:
a is type: <class 'int'>c is type: <class 'float'>e is type: <class 'complex'>71.41342756183745591.33333333333333331(5.66+8j)(8.66+12j)e's real part is: 5.66e's imaginary part is: 8.0sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
1 0
- 第5节--python数据类型--numeric
- Numeric 数据类型
- mysql decimal、numeric数据类型
- SQL Server numeric数据类型
- mysql decimal、numeric数据类型
- mysql decimal、numeric数据类型
- mysql decimal、numeric数据类型
- mysql decimal、numeric数据类型
- 第6节--python数据类型--string
- 第5课时.python的数据类型
- MySQL decimal、numeric数据类型介绍
- 2.2 数据类型2: Numeric & String
- Numeric Type -Learning Python
- 第五天-python数据类型-1
- 第五天-python数据类型-2
- sql server 数据类型numeric()等的用法!
- MySQL decimal、numeric 和double数据类型
- 第2章 Python基础语法 -- 数据类型
- 10.22
- 栈的应用之进制转换
- 10.23
- execute、executeQuery和executeUpdate之间的区别
- java各种toString方法
- 第5节--python数据类型--numeric
- 数据结构实验 矩阵的转置
- HDOJ 5738 Eureka
- Windows:使用virtualenv创建虚拟环境,安装pip
- codeforces 522A Reposts-找最长链长度dp[x]
- Android_获取发布版的秘钥(SHA1)和开发版的秘钥(SHA1)
- jsp获取文本,文本域,隐藏域的值
- hdu1175 连连看(bfs求拐弯次数)
- 179. Largest Number