Code used in the creation:
*************NOTE**************
For cost:
#given that an average car can contain 45-65 litres, we estimated an average of 55 litres fuel efficiency per car.
#choosing the Esso gas station as our target fuel provider, we calculated cost based on their current gas prices of $1.09/litre.
#in order to receive the final cost, we assumed that per every 1 km driven, 0.5 litres of fuel was consumed.
Fortinos - prices of one unit of the following groceries:
milkF = 4.59 eggsF = 5.19 breadF = 2.49 coffeeF = 7.29 yoghurtF = 2.49
Food Basics - prices of one unit of the following groceries:
milkFB = 4.39 eggsFB = 4.67 breadFB = 2.47 coffeeFB = 6.79 yoghurtFB = 2.77
Walmart - prices of one unit of the following groceries:
milkW = 4.47 eggsW = 3.18 breadW = 2.97 coffeeW = 4.97 yoghurtW = 2.67
while(True): #Number of units bought: try: NumMilk = abs(int(input("How many bags of milk will you buy? "))) NumEggs = abs(int(input("How many cartons of eggs will you buy? "))) NumBread = abs(int(input("How many loaves of bread will you buy? "))) NumCoffee = abs(int(input("How many containers of coffee will you buy? "))) NumYoghurt = abs(int(input("How many containers of yoghurt will you buy? ")))
#Store Chooser - user gets to input which store is chosen:
store = str(input("Which store will you choose? Fortinos, Food Basics or Walmart? "))
if store == "Fortinos":
#Mode of Transport Chooser - user gets to input which transport method is chosen:
mode = str(input("Which method of transportation do you prefer? Car, Bus or Uber? "))
try:
if mode == "Car":
cost = 0.9
time = 3
elif mode == "Bus":
cost = 3.25
time = 15
elif mode == "Uber":
cost = 11
time = 4
break
except (ValueError, NameError) as error:
print("Check your values and try again!")
price = ((NumMilk*milkF)+(NumEggs*eggsF)+(NumBread*breadF)+(NumCoffee*coffeeF)+(NumYoghurt*yoghurtF))*1.13 #tax included
elif store == "Food Basics":
#Mode of Transport Chooser - user gets to input which transport method is chosen:
mode = str(input("Which method of transportation do you prefer? Car, Bus or Uber? "))
try:
if mode == "Car":
cost = 1.14
time = 4
elif mode == "Bus":
cost = 3.25
time = 22
elif mode == "Uber":
cost = 12
time = 6
break
except (ValueError, NameError) as error:
print("Check your values and try again!")
price = ((NumMilk*milkFB)+(NumEggs*eggsFB)+(NumBread*breadFB)+(NumCoffee*coffeeFB)+(NumYoghurt*yoghurtFB))*1.13
elif store == "Walmart":
#Mode of Transport Chooser - user gets to input which transport method is chosen:
mode = str(input("Which method of transportation do you prefer? Car, Bus or Uber? "))
try:
if mode == "Car":
cost = 4.62
time = 13
elif mode == "Bus":
cost = 3.25
time = 37
elif mode == "Uber":
cost = 20
time = 14
break
except (ValueError, NameError) as error:
print("Check your values and try again!")
price = ((NumMilk*milkW)+(NumEggs*eggsW)+(NumBread*breadW)+(NumCoffee*coffeeW)+(NumYoghurt*yoghurtW))*1.13
#Opportunity Cost:
OppCost = round((price+cost),2)
print("This will cost you $", OppCost,"and it will take", time, "mins.")
break
except (ValueError, NameError) as error:
print("Check your values and try again!")

Log in or sign up for Devpost to join the conversation.