order1 = ('manan', 'holyoke', 'FLAT3', 'chicken', 'white', 'pinto', False, 'queso blanco', 'cheese', 'fajita veggies', 'sour cream')
order2 = ('allison', 'greenfield', 'MAGIC', 'carnitas', 'brown', 'black', True, 'cheese', 'fajita veggies', 'sour cream', 'guacamole', 'tomato salsa')
# 2a
def get_protein(order):
protein = order[3]
protein_prices = {
'chicken': 2.5,
'steak': 3.5,
'barbacoa': 3.5,
'carnitas': 3.0,
'veggies': 2.5,
'': 0
}
return protein_prices[protein]
# 2b
def get_rice(order):
rice = order[4]
rice_prices = {
'white': 2.5,
'brown': 3.5,
'': 0
}
return rice_prices[rice]
# 2c
def get_beans(order):
beans = order[5]
beans_prices = {
'black': 2.5,
'pinto': 2.5,
'': 0
}
return beans_prices[beans]
# 2d
def get_burrito(order):
burrito = order[6]
return 2.0 if burrito else 0
# 2e
def get_toppings(order):
toppings = order[7:]
toppings_prices = {
'guacamole': 2.75,
'tomato salsa': 2.5,
'chili corn salsa': 1.75,
'tomatillo green chili salsa': 2.0,
'sour cream': 2.5,
'fajita veggies': 2.5,
'cheese': 2.0,
'queso blanco': 2.75,
'': 0
}
if order[3] == 'veggies':
#1st point e dekho bola ase je protein choice "veggies" hole nicher duita free.
#tai 0 likhsi both
toppings_prices['guacamole'] = 0
toppings_prices['fajita veggies'] = 0
total_price = sum(toppings_prices[topping] for topping in toppings)
return total_price
# 2f
def apply_discount(order, total_price):
discount_code = order[2]
discount_codes = {
'MAGIC': 0.05,
'SUNDAYFUNDAY': 0.1,
'FLAT3': 3.0,
'none': 0
}
discount_rate = discount_codes[discount_code]
discounted_price = total_price * (1 - discount_rate)
return discounted_price
# 2g
def approximate_time(order):
location = order[1]
delivery_times = {
'amherst': 15,
'north amherst': 15,
'south amherst': 15,
'hadley': 15,
'northampton': 30,
'south hadley': 30,
'belchertown': 30,
'sunderland': 30,
'holyoke': 45,
'greenfield': 45,
'deerfield': 45,
'springfield': 45
}
return delivery_times[location]
# 2h
def generate_invoice(order):
customer_name = order[0]
protein_price = get_protein(order)
rice_price = get_rice(order)
beans_price = get_beans(order)
burrito_price = get_burrito(order)
toppings_price = get_toppings(order)
total_price = protein_price + rice_price + beans_price + burrito_price + toppings_price
discount_price = apply_discount(order, total_price)
money_saved = total_price - discount_price
approx_time = approximate_time(order)
print(f"Welcome to Chipotle Mexican Grill Hadley, {customer_name}.")
print("Your invoice is displayed below:")
print(f"Protein: {order[3]} - ${protein_price}")
print(f"Rice: {order[4]} rice - ${rice_price}")
print(f"Beans: {order[5]} beans - ${beans_price}")
print(f"Burrito: {'Yes' if order[6] else 'No'} - ${burrito_price}")
print(f"Toppings: {', '.join(order[7:])} - ${toppings_price}")
print(f"Subtotal: ${total_price}")
print(f"Discount Code: {order[2]}")
print(f"Total: ${discount_price}")
print(f"You Save: ${money_saved}")
print(f"Your order will be ready in {approx_time} minutes.")
print("Enjoy your meal and have a good day!")
generate_invoice(order1)
generate_invoice(order2)