Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: c3ceaaa930
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (18 sloc) 0.69 kB
import random
print('I will flip a coin 1000 times. Guess how many times it will come up heads. (Press enter to begin)')
input('> ')
flips = 0
heads = 0
while flips < 1000:
if random.randint(0, 1) == 1:
heads = heads + 1
flips = flips + 1
if flips == 900:
print('900 flips and there have been ' + str(heads) + ' heads.')
if flips == 100:
print('At 100 tosses, heads has come up ' + str(heads) + ' times so far.')
if flips == 500:
print('Half way done, and heads has come up ' + str(heads) + ' times.')
print()
print('Out of 1000 coin tosses, heads came up ' + str(heads) + ' times!')
print('Were you close?')
Jump to Line
Something went wrong with that request. Please try again.