zoukankan      html  css  js  c++  java
  • 数字

    1、数字类型

    整型:

    • 标准整型
    • 布尔型:True   False

    浮点型:注含十进制浮点型decimal模块

    复数:

    • 实数+虚数,虚数不能单独存在 real+imag j
    • 内建属性:num.real实部;num.imag虚部;num.conjugate()共轭复数

    2、转换函数

    int(),float(),complex(),bool()

    3、功能函数

    abs()注:以复数为参数时取模,divmod(),pow(),round()

    4、仅用于整型的内建函数

    In [19]: hex(25)  #字符串形式返回十六进制数
    Out[19]: '0x19'
    
    In [20]: oct(25)  #字符串形式返回八进制数
    Out[20]: '0o31'
    
    In [26]: ord('a')  #与chr相反
    Out[26]: 97
    
    In [27]: chr(97)  #ASCII值的数字-->ASCII字符,范围:0<=num<=255
    Out[27]: 'a'

    5、random模块

    randint(a,b)  # return  random  integer  in  range [a ,b]

    randrange()  #参数和range一样,choose  a  random  item  from  range(start,stop [,step])

    uniform(a,b)  # Get a random number in the range [a, b) or [a, b] depending on rounding

    random()  #无参数,然会浮点型,范围 [0.0 , 1.0 )

    choice(seq)  #随机返回给定序列的一个元素

    渐变 --> 突变
  • 相关阅读:
    C#方法重载 -0024
    C#表达式体方法 (expression-bodied method )
    C# 匿名类型 -0022
    C# 不可变类型 -0021
    C# 属性 -0020
    C# readonly和const -0019
    C# 类的静态成员和实例成员 -0018
    C#中类和结构体的区别 -0017
    C#预处理器指令 -0016
    微信小程序TabBar定义和配置
  • 原文地址:https://www.cnblogs.com/lybpy/p/8145057.html
Copyright © 2011-2022 走看看