import random run = 0 heads = 0.00 tails = 0.00 while run != 10000: number = random.randint(1,2) if number == 1: heads = heads+1 else: tails = tails+1 run = run+1 if tails > heads: print ("There were more tails than heads that time.") if heads > heads or tails > tails: print ("LOL I just broke the laws of physics!") if heads > tails: print ("There were more heads than tails that time.") if tails = heads: print ("There were exactly the same number of heads and tails that time.") print "That was ",heads/100,"% heads and ",tails/100,"% tails." print "There were",heads,"heads and",tails,"tails!"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question