Created
February 15, 2012 15:38
-
-
Save ChrisMoney/d6c6b5c7de3ed829bacc to your computer and use it in GitHub Desktop.
Python --Coin Toss Program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Coin Toss Program | |
| 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 | |
| userinput = raw_input("or another key to toss again:") | |
| print "the total number of heads:", headcount | |
| print "the total number of tails: ", tailcount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment