Create a gist now

Instantly share code, notes, and snippets.

anonymous /cointoss
Created Apr 23, 2012

cointoss
import random
import sys
def main():
class test:
number_given = 1
while number_given != 0:
number = input('Enter the number of times you want the coin to be flipped: ')
number_given = number
if number > 0:
tails = 0
heads = 0
for count in range(number):
coin_toss = random.randint(0,1)
if coin_toss == 0:
print "tails"
tails += 1
else:
print "heads"
heads += 1
print("You flipped %d heads and %d tails." % (heads, tails))
else:
sys.exit()
test()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment