Skip to content

Instantly share code, notes, and snippets.

@mitgr81
Created March 20, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mitgr81/5554ca310bf8e9015726 to your computer and use it in GitHub Desktop.
Save mitgr81/5554ca310bf8e9015726 to your computer and use it in GitHub Desktop.
Tipper
percentify = lambda number, percentage: float(number) * (percentage / 100)
restaraunt_tax_percentage = 6.75
tip_percentage = 15
meal = float(input("How much was the meal? $") or 44.50)
restaraunt_tax = percentify(meal, restaraunt_tax_percentage)
tip = percentify(meal + restaraunt_tax, tip_percentage)
print("Your tip should be ${:.2f}".format(tip))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment