jeudi 26 mai 2016

Python assign variable names to if else function

# Determine price per pound
if quantity >= 40:
print('Cost of coffee $', format(quantity * 7.50,'.2f'),sep='')
else:
if quantity >= 20:
print ('Cost of coffee $', format(quantity * 8.75, '.2f'), sep='')
else:
if quantity >= 10:
print ('Cost of coffee $', format (quantity * 10.00, '.2f'), sep='')
else:
if quantity >= 1 or quantity <= 9:
print ('Cost of coffee $', format (quantity * 12.00, '.2f'), sep='')

Im trying to figure out how I get the total (cost per pound * quantity entered) assigned to a variable. I need to be able to take the total before tax and multiple it by 7% tax. Above is the formula I have to find out how much it will cost based on the quantity and price.

Aucun commentaire:

Enregistrer un commentaire