Lemonade Stand: Difference between revisions
| Line 82: | Line 82: | ||
#Generisize the names of supplys to make it easily editable | #Generisize the names of supplys to make it easily editable | ||
name = 'Lemonade Stand' | #[0] = name of the stand, [1] = first supply, [2] = second supply, [3] = third supply, [4] = the object that is being sold | ||
variables = ['Lemonade Stand','cups','lemons','sugar','cups'] | |||
print 'Welcome to ' + | print 'Welcome to ' + variables[0] | ||
| Line 125: | Line 122: | ||
print "" | print "" | ||
#Decreases currently the supplys by 10% each day | |||
def supply_Decay(): | def supply_Decay(): | ||
global stored_sugar, stored_lemons, stored_cups | global stored_sugar, stored_lemons, stored_cups | ||
| Line 167: | Line 166: | ||
print "You have "+`stored_cups`+ " " + | print "You have "+`stored_cups`+ " " + variables[1] + ", " +`stored_lemons`+ " " + variables[2] + ", and "+`stored_sugar`+ " " + variables[3] + " left." | ||
print | print variables[1] + " price: $" + `cup_price` + " " + variables[2] + " price: $"+ "%.2f" % lemon_price + " " + variables[3] + " price: $"+ "%.2f" % sugar_price | ||
expenses = 0 | expenses = 0 | ||
| Line 181: | Line 180: | ||
potential_expense = 0 | potential_expense = 0 | ||
in_num = take_input("How many " + | in_num = take_input("How many " + variables[1]) | ||
potential_expense = expenses + (in_num * cup_price) | potential_expense = expenses + (in_num * cup_price) | ||
| Line 189: | Line 188: | ||
stored_cups += in_num | stored_cups += in_num | ||
else: | else: | ||
print 'You cant afford that many ' + | print 'You cant afford that many ' + variables[1] | ||
cost_over = 1 | cost_over = 1 | ||
| Line 196: | Line 195: | ||
potential_expense = 0 | potential_expense = 0 | ||
in_num = take_input("How many " + | in_num = take_input("How many " + variables[2]) | ||
potential_expense = expenses + (in_num * cup_price) | potential_expense = expenses + (in_num * cup_price) | ||
| Line 204: | Line 203: | ||
stored_lemons += in_num | stored_lemons += in_num | ||
else: | else: | ||
print 'You cant afford that many ' + | print 'You cant afford that many ' + variables[2] | ||
cost_over = 1 | cost_over = 1 | ||
| Line 211: | Line 210: | ||
potential_expense = 0 | potential_expense = 0 | ||
in_num = take_input("How much " + | in_num = take_input("How much " + variables[3]) | ||
potential_expense = expenses + (in_num * cup_price) | potential_expense = expenses + (in_num * cup_price) | ||
| Line 220: | Line 219: | ||
else: | else: | ||
print 'You cant afford that many ' + | print 'You cant afford that many ' + variables[3] | ||
today = min(stored_cups, stored_lemons, stored_sugar) | today = min(stored_cups, stored_lemons, stored_sugar) | ||
| Line 238: | Line 237: | ||
stored_lemons -= sales | stored_lemons -= sales | ||
stored_sugar -= sales | stored_sugar -= sales | ||
print `sales`+" | print `sales`+ ' ' + variables[4]+ " made for $"+ "%.2f" % expenses | ||
profit = sales * product_price | profit = sales * product_price | ||
print `sales`+ " " + | print `sales`+ " " + variables[4] +" were sold today for $"+ "%.2f" % profit | ||
print "You made $"+ "%.2f" % (profit - expenses)+" today." | print "You made $"+ "%.2f" % (profit - expenses)+" today." | ||
bank += profit - expenses | bank += profit - expenses | ||