Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Coin Flipper Program
- #
- #Dustin Hammack
- #Feb. 4, 2017
- import random
- print('\t\t\tLets see how lucky you are. ')
- print('\t\t\tHere you will choose either heads or tails, ')
- print('\t\t\tand see if you can win the flip. Best out of ')
- print('\t\t\t100 wins. \n\n\n')
- def flippedCoin():
- userChoice = input('\nPlease choose heads or tails: ')
- print()
- choice = userChoice.lower()
- heads = random.randrange(1,100)
- tails = 100 - heads
- if (choice == 'heads'):
- if (heads > tails):
- print('You won with ' + str(heads) + ' flips.')
- print('And tails lost with only ' + str(tails) + ' flips.')
- elif (tails > heads):
- print('You lost with only ' + str(heads) + ' flips.')
- print('And tails won with ' + str(tails) + ' flips.')
- print('\n\nTry your luck again?')
- elif (heads == tails):
- print('It was a tie!')
- playingAgain()
- elif (choice == 'tails'):
- if (heads < tails):
- print('You won with ' + str(tails) + ' flips.')
- print('And heads lost with only ' + str(heads) + ' flips.')
- elif (tails < heads):
- print('You lost with only ' + str(tails) + ' flips.')
- print('And heads won with ' + str(heads) + ' flips.')
- print('\n\nTry your luck again?')
- elif (heads == tails):
- print('It was a tie!')
- playingAgain()
- else:
- print('\nPlease enter only "heads" or "tails"')
- flippedCoin()
- playingAgain()
- def playingAgain():
- playAgain = input('\n\nWould you like to play again? ')
- again = playAgain.lower()
- if (again == 'yes'):
- flippedCoin()
- elif (again == 'no'):
- print('\n\nThanks for playing. See you next time!')
- elif (again != 'yes' and again != 'no'):
- print('Please enter Yes or No ')
- playingAgain()
- flippedCoin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement