Guest User

Untitled

a guest
Jul 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import time
  2. import random
  3. headcount = tailcount = 0
  4. userinput = ' '
  5. print ("now tossing a coin...")
  6. while userinput.lower () != "q":
  7.     flip = random.choice(['heads', 'tails'])
  8.     if flip == 'heads':
  9.         headcount += 1
  10.         print "heads! the number of heads is now %d" % headcount
  11.     else:
  12.         tailcount += 1
  13.         print "tails! the number of tails is now %d" % tailcount
  14.     print ("press 'q' to quit")
  15.     userinput = raw_input ("or another key to flip again:")
  16.     print"the total number of heads is now %d" % headcount
  17.     print"the total number of tails is now %d" % tailcount
Add Comment
Please, Sign In to add comment