Recipe Finder Project With Index
Recipe Finder Project With Index
Project Overview
The Recipe Finder project helps users find recipes they can make with ingredients they already
have. The program contains a list of recipes with ingredients and lets users either add a new
recipe or search for recipes based on available ingredients.
Project Code
Below is the code, split into simple parts with explanations.
# Recipe Database
recipes = {
Explanation: This recipes dictionary is like a mini recipe book. Each recipe has a list of
ingredients needed to make it.
if recipe_name in recipes:
else:
recipes[recipe_name] = ingredients
matching_recipes = []
matching_recipes.append(recipe)
if matching_recipes:
print(f"- {recipe}")
else:
Explanation: find_recipes() goes through each recipe and checks if all ingredients
are available. If a recipe matches, it’s added to a list of recipes the user can make. If
no recipes match, a message is shown.
def main():
while True:
print("\nOptions:")
print("3. Exit")
choice = input("Enter your choice (1/2/3): ")
if choice == "1":
add_recipe(recipe_name, ingredients)
find_recipes(available_ingredients)
break
else:
Explanation:
1. The main() function displays options to the user: add a recipe, search for recipes, or
exit.
Here’s the full, simplified code to copy into your Word document:
python
# Recipe Database
recipes = {
if recipe_name in recipes:
else:
recipes[recipe_name] = ingredients
def find_recipes(available_ingredients):
matching_recipes = []
matching_recipes.append(recipe)
if matching_recipes:
else:
def main():
while True:
print("\nOptions:")
print("3. Exit")
if choice == "1":
add_recipe(recipe_name, ingredients)
find_recipes(available_ingredients)
else:
if __name__ == "__main__":
main()
1. Dictionary Use: Explain how the recipes dictionary stores recipes as keys and ingredients
as values.
2. Functions: add_recipe() adds recipes, and find_recipes() checks for matching recipes.
3. Loop Control: main() uses a loop to allow repeated actions until the user exits.
4. Conditionals: Different actions are taken based on user choices (adding recipes, searching,
exiting).
This structured breakdown should make it easier to understand and edit for a Word document
and viva preparation.