{
}
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
Typescript Online 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
Ends in
Buy 1 year, 🎁 Gift 1 year — completely FREE
Split the cost with a friend. You both get 12 months for $99.
Buy 1 year, Gift 1 year —completely FREE
Start FREE Trial
Start FREE Trial
Ends in
Buy 1 year, 🎁 Gift 1 year — completely FREE
Split the cost with a friend. You both get 12 months for $99.
Buy 1 year, Gift 1 year —completely FREE
Start FREE Trial
Start FREE Trial
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