|
|}
<syntaxhighlight lang="python">
# List of recipes with their ingredients, costs, sold price, and profit
recipes = [
{
"name": "Bacon Sandwich",
"ingredients": [("Bread", 200), ("Bacon", 200)],
"sold_price": 560,
"profit": 160
},
{
"name": "Appetizing Bacon Sandwich",
"ingredients": [("Bread", 200), ("Appetizing Bacon", 320)],
"sold_price": 776,
"profit": 256
},
{
"name": "Basic Omelette",
"ingredients": [("Egg", 240)],
"sold_price": 336,
"profit": 96
},
{
"name": "Basic Sausage and Mash",
"ingredients": [("Raw Sausage", 260), ("Potato", 700)],
"sold_price": 850,
"profit": -110
},
{
"name": "Basic Vegetable Stew",
"ingredients": [("Mixed Vegetables", 280)],
"sold_price": 492,
"profit": 212
}
]
# Function to calculate the total cost of ingredients for each recipe
def calculate_total_cost(ingredients):
return sum(cost for ingredient, cost in ingredients)
Profit purchasing from Kevin's Ingredients and selling to the Head Chef
# Function to generate and print a Wiki-style markdown table
{| class="wikitable"
def generate_wiki_table(recipes):
!Recipe
# Table header
!Item 1
table_header = "| Recipe | Total Ingredient Cost | Sold Price | Profit | Expected Profit |"
!Cost
separator = "|--------|-----------------------|------------|--------|-----------------|"
!Item 2
!Cost
# Print the header and separator
!Sold
print(table_header)
!Profit
print(separator)
|-
|Bacon Sandwhich
# Iterate over each recipe and print the data in a markdown table format
|Bread
for recipe in recipes:
|200
total_cost = calculate_total_cost(recipe["ingredients"])
|Bacon
expected_profit = recipe["sold_price"] - total_cost
|200
print(f"| {recipe['name']} | {total_cost} | {recipe['sold_price']} | {recipe['profit']} | {expected_profit} |")
|560
|160
# Display the Wiki-style table
|-
generate_wiki_table(recipes)
|Appetizing Bacon Sandwhich
</syntaxhighlight>
|Bread
|200
|Appetizing Bacon
|320
|776
|256
|-
|Basic Omelette
|Egg
|240
|
|
|336
|96
|-
|Basic Sausage and Mash
|Raw Sausage
|260
|Potato
|700
|850
| -110
|-
|Basic Vegetable Stew
|Mixed Vegetables
|280
|
|
|492
|212
|}
==Update history==
|