Skip to content

Instantly share code, notes, and snippets.

Created April 23, 2012 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2473672 to your computer and use it in GitHub Desktop.
Save anonymous/2473672 to your computer and use it in GitHub Desktop.
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