Advertisement
Guest User

Python coin flipper(stack overflow info)*Fixed

a guest
Jan 17th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.77 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4. #Picking up the coin array
  5. comment = ["Finding the coin...", "Saving the world from a massive plague...", "Actually flipping a coin...", "Introducing Bias...", "Hacking your computer...", "Entering the matrix...", "Making Python bite...", "Giving all your details to the NSA...", "Thinking of more phrases...", "Stealing your bank account details...", "Planning mission to SePT-A 51..."]
  6.  
  7. #side of coin, so no errors
  8. side = 1
  9.  
  10. #assigns variables first
  11. headcount = 0
  12. tailcount = 0
  13.  
  14. #Coin flip array
  15. coin = ["Heads", "Tails"]
  16.  
  17. #Reset of counts
  18. def resetheadtail():
  19.     headcount = 0
  20.     tailcount = 0
  21.     side = 1
  22.  
  23. #Flip program
  24.     def flipit(random, time, comment, headcount, tailcount, side):
  25.         time.sleep(1)
  26.         print("It begins...")
  27.         print("\n")
  28.         for x in range(0, 10):
  29.             print("Flip number", x + 1)
  30.             side = random.choice(coin) # get the random choice
  31.             print(random.choice(comment))
  32.             time.sleep(1)
  33.             print(side) # print it
  34.             if side == "Heads":
  35.                 headcount += 1
  36.             else:
  37.                 tailcount += 1
  38.             time.sleep(2)
  39.             print("\n")
  40.         print("You got", headcount, "heads and", tailcount, "tails!")
  41.         print("Type start() to begin flipping coins again")
  42.         resetheadtail()
  43.  
  44. #Startup routine
  45. def startup(time):
  46.     #Coundown
  47.     print("Coins will start falling in...\n5")
  48.     time.sleep(1)
  49.     print("\n4")
  50.     time.sleep(1)
  51.     print("\n3")
  52.     time.sleep(1)
  53.     print("\n2")
  54.     time.sleep(1)
  55.     print("\n1")
  56.     time.sleep(1)
  57.     print("\n")
  58.     flipit(random, time, comment, headcount, tailcount, side)
  59.  
  60. #Ease of access
  61. def begin():
  62.     startup(time)
  63.  
  64. begin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement