Python整型运算之布尔型、标准整型、长整型操作示例
作者:坏蛋是我 时间:2021-01-28 06:39:15
本文实例讲述了Python整型运算之布尔型、标准整型、长整型操作。分享给大家供大家参考,具体如下:
#coding=utf8
def integerType():
'''''
布尔型:
该值的取值范围只有两个值:True(1)、False(0)
'''
Tbool=True
Fbool=False
print "The True is stand for %d" %(Tbool)
print "The False is stand for %d" %(Fbool)
'''''
python标准整数类型:
Python标准整数类型是最通用的数字类型。
在大多数32位机器上,标准整数类型的取值范围:-2147483648 到 2147483647
Python标准整数类型等价于C的有符号长整型。
八进制整数以数字“0”开始。
十六进制整数以“0x”或“0X”开始
'''
bInt=010101
dInt=84455555
oInt=075
hInt=0xabc
print "The binary of the standard integer:",bInt
print "The decimal of the standard integer:",dInt
print "The octal of the standard integer:",oInt
print "The hexadecimal of the standard integer:",hInt
'''''
python长整型:
Python长整型能表达的数值仅仅与机器值的(虚拟)内存大小有关。
长整数类型是标准整数类型的超集。
在一个整数值后面加上个L(大写或小写都可以,推荐使用大写,避免和数字1混淆),表示这个整数时长整数。
这个整数可以是十进制、八进制、十六进制。
只有对长整数调用repr()才有机会看到L,对长整数调用str()看不到L。
整型和长整型正在统一为一种。
'''
bLong=0111111111111111111111111111111111111111111111L
dLong=8888888888888888888888888888888888888888888888L
oLong=0777777777777777777777777777777777777777777777L
hLong=0XFFFFFFFFFFFFFFFFFAAAAAAAAAAAAABBBBBBBBBB78L
print "The binary of the long integer:",repr(bLong)
print "The decimal of the long integer:",repr(dLong)
print "The octal of the long integer:",repr(oLong)
print "The hexadecimal of the long integer:",repr(hLong)
'''''call the function : integerType()'''
integerType()
运行结果如下图:
PS:这里再为大家推荐几款计算工具供大家进一步参考借鉴:
在线一元函数(方程)求解计算工具:
http://tools.jb51.net/jisuanqi/equ_jisuanqi
科学计算器在线使用_高级计算器在线计算:
http://tools.jb51.net/jisuanqi/jsqkexue
在线计算器_标准计算器:
http://tools.jb51.net/jisuanqi/jsq
希望本文所述对大家Python程序设计有所帮助。
标签:Python,运算
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
详解python日期时间处理2
2021-05-20 19:27:15
![](https://img.aspxhome.com/file/2023/3/86613_0s.png)
Python实现统计给定字符串中重复模式最高子串功能示例
2023-07-22 23:42:44
Python使用add_subplot与subplot画子图操作示例
2022-12-15 13:14:28
![](https://img.aspxhome.com/file/2023/2/67812_0s.png)
Python在for循环中更改list值的方法【推荐】
2023-03-05 07:14:28
python字典嵌套字典的情况下找到某个key的value详解
2021-12-07 12:04:37
YOLOv8训练自己的数据集(详细教程)
2021-07-12 20:59:18
![](https://img.aspxhome.com/file/2023/6/96986_0s.jpg)
基于python和flask实现http接口过程解析
2022-06-01 11:46:36
Python 可迭代对象 iterable的具体使用
2021-08-28 08:24:32
设计提升满意度
2010-05-16 15:00:00
![](https://img.aspxhome.com/file/UploadPic/20105/16/01-60s.jpg)
Python实现二维数组按照某行或列排序的方法【numpy lexsort】
2022-03-13 05:06:31
Python求出0~100以内的所有素数
2023-09-17 16:54:02
如何创建并使用一个断开连接的记录集的数据访问页?
2009-11-14 20:50:00
浅谈pytorch 模型 .pt, .pth, .pkl的区别及模型保存方式
2023-11-25 12:41:38
Python开发网站目录扫描器的实现
2022-07-09 11:51:02
![](https://img.aspxhome.com/file/2023/7/86337_0s.png)
一列保存多个ID(将多个用逗号隔开的ID转换成用逗号隔开的名称)
2012-08-21 10:37:37
python实现简易云音乐播放器
2021-07-02 10:13:43
Web 标准设计实践:Google 的首页
2008-10-12 12:14:00
再读《你是一个职业的页面重构工作者吗?》
2009-02-11 12:22:00
浅谈php自定义错误日志
2023-11-14 10:59:40
那些被我遗忘掉的XHTML标签们
2008-06-07 14:27:00