Python整型运算之布尔型、标准整型、长整型操作示例


Posted in Python onJuly 21, 2017

本文实例讲述了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)
  print
  '''''
  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
  print
  '''''
  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)
  print
'''''call the function : integerType()'''
integerType()

运行结果如下图:

Python整型运算之布尔型、标准整型、长整型操作示例

PS:这里再为大家推荐几款计算工具供大家进一步参考借鉴:

在线一元函数(方程)求解计算工具:
http://tools.3water.com/jisuanqi/equ_jisuanqi

科学计算器在线使用_高级计算器在线计算:
http://tools.3water.com/jisuanqi/jsqkexue

在线计算器_标准计算器:
http://tools.3water.com/jisuanqi/jsq

希望本文所述对大家Python程序设计有所帮助。

Python 相关文章推荐
python使用在线API查询IP对应的地理位置信息实例
Jun 01 Python
Python多线程编程(一):threading模块综述
Apr 05 Python
Python+matplotlib绘制不同大小和颜色散点图实例
Jan 19 Python
python中virtualenvwrapper安装与使用
May 20 Python
python批量修改文件编码格式的方法
May 31 Python
Python图像处理实现两幅图像合成一幅图像的方法【测试可用】
Jan 04 Python
Python之数据序列化(json、pickle、shelve)详解
Aug 30 Python
基于python plotly交互式图表大全
Dec 07 Python
基于pandas中expand的作用详解
Dec 17 Python
python剪切视频与合并视频的实现
Mar 03 Python
Python字符串split及rsplit方法原理详解
Jun 29 Python
python urllib库的使用详解
Apr 13 Python
Python双精度浮点数运算并分行显示操作示例
Jul 21 #Python
详解Golang 与python中的字符串反转
Jul 21 #Python
Python随机生成手机号、数字的方法详解
Jul 21 #Python
Python实现将16进制字符串转化为ascii字符的方法分析
Jul 21 #Python
windows下Python实现将pdf文件转化为png格式图片的方法
Jul 21 #Python
python僵尸进程产生的原因
Jul 21 #Python
python下载图片实现方法(超简单)
Jul 21 #Python
You might like
php运行出现Call to undefined function curl_init()的解决方法
2010/11/02 PHP
Mysql中分页查询的两个解决方法比较
2013/05/02 PHP
php利用新浪接口查询ip获取地理位置示例
2014/01/20 PHP
php实现mysql数据库操作类分享
2014/02/14 PHP
教你如何解密 “ PHP 神盾解密工具 ”
2014/06/20 PHP
php5.4以上版本GBK编码下htmlspecialchars输出为空问题解决方法汇总
2015/04/03 PHP
PHP MVC框架skymvc支持多文件上传
2016/05/26 PHP
jquery向.ashx文件post中文乱码问题的解决方法
2011/03/28 Javascript
javascript 弹出层组件(升级版)
2011/05/12 Javascript
解决jQuery动态获取手机屏幕高和宽的问题
2014/05/07 Javascript
JavaScript点击按钮后弹出透明浮动层的方法
2015/05/11 Javascript
基于jQuery实现的旋转彩圈实例
2015/06/26 Javascript
基于javascript实现checkbox复选框实例代码
2016/01/28 Javascript
Express使用html模板的详细代码
2017/09/18 Javascript
JavaScript引用类型Array实例分析
2018/07/24 Javascript
jQuery实现的导航条点击后高亮显示功能示例
2019/03/04 jQuery
基于layPage插件实现两种分页方式浅析
2019/07/27 Javascript
vant自定义二级菜单操作
2020/11/02 Javascript
[10:42]Team Liquid Vs Newbee
2018/06/07 DOTA
开始着手第一个Django项目
2015/07/15 Python
Python命令行解析模块详解
2018/02/01 Python
利用Python如何批量更新服务器文件
2018/07/29 Python
python使用pdfminer解析pdf文件的方法示例
2018/12/20 Python
Python实现定制自动化业务流量报表周报功能【XlsxWriter模块】
2019/03/11 Python
Django模型中字段属性choice使用说明
2020/03/30 Python
聚网科技C++面试笔试题
2015/09/01 面试题
单位工程竣工验收方案
2014/03/16 职场文书
银行竞聘演讲稿
2014/05/16 职场文书
2014保险公司个人工作总结
2014/12/09 职场文书
2016中学教师读书心得体会
2016/01/13 职场文书
公安纪律作风整顿心得体会
2016/01/23 职场文书
晶体管来复再生式二管收音机
2021/04/22 无线电
教你漂亮打印Pandas DataFrames和Series
2021/05/29 Python
Vue3.0中Ref与Reactive的区别示例详析
2021/07/07 Vue.js
手把手教你使用TensorFlow2实现RNN
2021/07/15 Python
python 多态 协议 鸭子类型详解
2021/11/27 Python