Skip to content

Instantly share code, notes, and snippets.

@spaghettiSyntax
Created December 6, 2017 07:06
Show Gist options
  • Save spaghettiSyntax/ffc1b395339634592e4594cdb5deb41b to your computer and use it in GitHub Desktop.
Save spaghettiSyntax/ffc1b395339634592e4594cdb5deb41b to your computer and use it in GitHub Desktop.
Tony Gaddis Python: Tip, Tax, Food
# Tip, Tax Food Calculator
# First Flowchart problem homework 1
# We will use 18% as the tip rate
TIP_PERCENTAGE = 0.18
# Currently the tax rate is 9%
TAX_PERCENTAGE = 0.09
charge_for_food = float(input('Input charge for food: '))
tip = TIP_PERCENTAGE * charge_for_food
tax = TAX_PERCENTAGE * charge_for_food
total = charge_for_food + tip + tax
# + tip + tax works and is a LOGIC error, will still run without syntax issues.
#Leaving off the f on .2f will make numbers go into exponential notation
print('Charge for food: $', format(charge_for_food, ',.2f'), sep = '')
print('Tip: $', format(tip, ',.2f'), sep = '')
print('Tax: $', format(tax, ',.2f'), sep = '')
print('Total: $', format(total, ',.2f'), sep = '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment