Skip to content

Instantly share code, notes, and snippets.

@Mathsmaniac
Created July 9, 2021 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mathsmaniac/86256ed328964902d2439a55749995d7 to your computer and use it in GitHub Desktop.
Save Mathsmaniac/86256ed328964902d2439a55749995d7 to your computer and use it in GitHub Desktop.
Calculate winnings for session
"""Component 3 of Lucky Unicorn game - winnings system
Calculate winnings for session
Assumes starting balance of $10 and allows manual input of token for testing purposes
Created by Nathan Smith
08/07/2021
"""
# Assuming starting balance of $10
user_balance = 10
UNICORN_PAYOUT = 5
HORSE_ZEBRA_PAYOUT = 0.5
# allow manual token input for testing purposes
token = input("Enter token to test: ").lower()
# Adjust user_balance correctly for given token
if token == "unicorn":
user_balance += 4
print("Congratulations, you won ${:.2f}".format(UNICORN_PAYOUT))
elif token == "horse" or token == "zebra":
user_balance -= 0.5
print("Congratulations, you won ${:.2f}".format(HORSE_ZEBRA_PAYOUT))
else:
user_balance -= 1
print("Sorry, you did not win anything this round")
print("You have ${:.2f} left to play with".format(user_balance))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment