Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- headcount = tailcount = 0
- userinput = ' '
- print ("now tossing a coin...")
- while userinput.lower () != "q":
- flip = random.choice(['heads', 'tails'])
- if flip == 'heads':
- headcount += 1
- print ("heads! the number of heads is now %d" % headcount)
- else:
- tailcount += 1
- print ("tails! the number of tails is now %d" % tailcount)
- print ("press 'q' to quit")
- userinput = input ("or another key to flip again:")
- print("the total number of heads is now %d" % headcount)
- print("the total number of tails is now %d" % tailcount)
Add Comment
Please, Sign In to add comment