欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

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

时间:2021-10-13 09:09:52|栏目:Python代码|点击:

本文实例讲述了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()

运行结果如下图:

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

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

科学计算器在线使用_高级计算器在线计算:
http://tools.jb51.net/jisuanqi/jsqkexue

在线计算器_标准计算器:
http://tools.jb51.net/jisuanqi/jsq

更多关于Python相关内容感兴趣的读者可查看本站专题:《Python数学运算技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总

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

上一篇:HTML中使用python屏蔽一些基本功能的方法

栏    目:Python代码

下一篇:10个顶级Python实用库推荐

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

本文地址:http://www.codeinn.net/misctech/179726.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有