logo
  • 教程列表
  • SO官方文檔
  • 隨機模組
    • 建立隨機使用者密碼
    • 隨機和序列隨機選擇和樣本
    • 建立隨機整數和浮動 randint randrange 隨機和統一
    • 建立加密安全隨機數
    • 可重複的隨機數種子和狀態
    • 隨機二元決策
  1. StackOverflow 文件
  2. Python Language 教程
  3. 隨機模組
  4. 隨機二元決策

隨機二元決策

Created: November-22, 2018

import random

probability = 0.3

if random.random() < probability:
    print("Decision with probability 0.3")
else:
    print("Decision with probability 0.7")
  • 可重複的隨機數種子和狀態

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明