• 技术文章 >Python技术 >Python基础教程

    python定义数值类型变量的方法

    小妮浅浅小妮浅浅2021-07-28 09:11:56原创4125

    说明

    1、Python内置了很多数值类型,其中常用的有int和float。

    2、var1是int类型的变量,与数学中的整数相对应,其范围为(-inf,inf),即大。

    实例

    >>> a = 100
    >>> type(a)
    <class 'int'>
     
    >>> b = 10**1000
    >>> b
    10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    >>> type(b)
    <class 'int'>

    以上就是python定义数值类型变量的方法,希望对大家有所帮助。更多Python学习指路:python基础教程

    本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

    专题推荐:python 数值类型
    上一篇:python如何用循环遍历分离数据 下一篇:python数值类型的使用整理

    相关文章推荐

    • 什么是网络协议• python中的去除重复项的操作• python中少见的函数map()和partial()• python的sort()排序方法• Python中的文件读写-理论知识

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网