{
}
Online Python Compiler
Online R Compiler
Online SQL Editor
Online HTML/CSS Editor
Online Java Compiler
Online C Compiler
Online C++ Compiler
Online C# Compiler
Online JavaScript Compiler
Online Typescript Compiler
Online GoLang Compiler
Online Rust Compiler
Scala Online Compiler
Dart Online Compiler
Ruby Online Compiler
Online PHP Compiler
Online Swift Compiler
Generating Link
Generating Link
Share your code
Share code
Copy Link
Copied to clipboard
or share using
62
%
OFF
Stop copy pasting code you don't actually understand
Build the coding confidence you need to become a developer companies will fight for
Stop copy pasting code you don't actually understand
Become a PRO
Become a PRO
62
%
OFF
Stop copy pasting code you don't actually understand
Build the coding confidence you need to become a developer companies will fight for
Stop copy pasting code you don't actually understand
Become a PRO
Become a PRO
Python Online Compiler
Learn Python App
Learn Python
main.py
Output
main.py
Share
Run
Run
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
Clear