zoukankan      html  css  js  c++  java
  • random模块

    random.randint(1,10)     # 产生 1 到 10 的一个整数型随机数  
     random.random()             # 产生 0 到 1 之间的随机浮点数
    random.uniform(1.1,5.4)      # 产生  1.1 到 5.4 之间的随机浮点数,区间可以不是整数
    random.choice('tomorrow')    # 从序列中随机选取一个元素
    random.randrange(1,100,2)   # 生成从1到100的间隔为2的随机整数
    
    a=[1,3,5,6,7]                # 将序列a中的元素顺序打乱
    random.shuffle(a)
  • 相关阅读:
    POJ 2689
    NEFU 109
    HDU 2098
    NEFU 2
    NEFU 117
    NEFU 84
    POJ 1061
    NEFU116 GCD
    NEFU 115
    HDU 2099
  • 原文地址:https://www.cnblogs.com/baoshilin/p/12487579.html
Copyright © 2011-2022 走看看