public
anonymous / cointoss
Created

cointoss

  • Download Gist
cointoss
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.