加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gambler.py 451 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jérôme Krell 提交于 2019-10-10 14:22 . Reformat Code by PyCharm-Community
import random
from sys import argv
stake = int(argv[1])
goals = int(argv[2])
trials = int(argv[3])
wins = 0
bets = 0
for i in range(trials):
cash = stake
while cash > 0 and cash < goals:
bets += 1
if random.randrange(0, 2) == 0:
cash += 1
else:
cash -= 1
if cash == goals:
wins += 1
print("Your won: " + str(100 * wins // trials) + "$")
print("Your bets: " + str(bets // trials))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化