{}
BLACK FRIDAY SALE
Get Programiz PRO for LIFE at 60% off!
Claim My Discount
Sale ends in
BLACK FRIDAY
Save 60% on PRO: Sale Ends Soon!
Claim My Discount
run-icon
main.py
import random import statistics hist = [] PROB = 256 GOAL = 19 while True: dropped = 0 trial = 0 input("ENTERキーを押してドロップ率{}分の1のタネを{}個手に入れるまで戦闘を試行します".format(PROB, GOAL)) while dropped < GOAL: trial += 1 if random.randint(0, PROB-1) == 0: dropped += 1 hist.append(trial) print("{}個タネを落とすまでに{}回の戦闘をしました".format(GOAL, trial)) print("{}回試行して平均して{}回の戦闘をしています".format(len(hist), statistics.mean(hist))) print("標準偏差は{}です\n".format(statistics.pstdev(hist)))
Output