0% found this document useful (0 votes)
9 views21 pages

Python Calorie Counting Script

This document describes a Python script designed to replace MyFitnessPal for tracking calories and nutrition in meals. It allows users to define custom ingredients and recipes, calculate nutrition per serving, and adjust servings based on desired protein intake. The script is user-friendly, requiring no coding knowledge, and can be run in Google Colab.

Uploaded by

gash1807
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views21 pages

Python Calorie Counting Script

This document describes a Python script designed to replace MyFitnessPal for tracking calories and nutrition in meals. It allows users to define custom ingredients and recipes, calculate nutrition per serving, and adjust servings based on desired protein intake. The script is user-friendly, requiring no coding knowledge, and can be run in Google Colab.

Uploaded by

gash1807
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Hello! Welcome to my python script that is made to replace MyFitnessPal.

I made this
script to track my calories without the use of a paid calorie tracking app such as
MyFitnessPal. You can edit it however you want with any ingredient you so choose, and I will
show you how you can use this script with absolutely zero coding knowledge. You can also
accurately count the calories in meals that you want to make. You must note that every
thing needs to be measured out carefully in grams, even including those items that seem
they have no nutritional value must be included in your recipes, for when you go to divide
your meal up in grams the weight of all items matter, unless its something very miniscule
like cilantro. This script will take a little bit to get used to it, but I have it setup in such a way
that you make any additions to it that you want when it comes to adding ingredients and
recipes. It is a little time consuming having to set up the recipes and ingredients and
weighing everything up but it beats having to pay for MyfitnessPal. I like to use nutritionix to
find nutrition facts for ingredients.

First for those of us with zero coding knowledge, that’s okay, use can go to google colab and
use their free python coding interface. Just copy and paste my script into the +code section
and hit the run button.

For Example, you want to add an ingredient, bok choy to your “Define Ingredients” section,
you would enter something like this:

bok_choy = CustomIngredient("bok choy", 170, 20, 1.7, 3, 0, 2.7, 1.4, 0)

Where, everything in the paranthesis refers to these items:

name, serving_size, calories, fiber, carbs, fat, protein, sugar, sodium

This means that for every 170 grams of bok choy you will find 20 calories, 1.7g of fiber 3g of
carbs, etc.

Then, when you create a meal with bok choy in it for example a beef stew you would include
the ingredient in your beef stew recipe, with the weight of bok choy that went into your
recipe:

Beef_stew = Recipe()

Beef_stew.add_ingredient(chuck_roast, 1159)

Beef_stew.add_ingredient(bok_choy, 186)

Beef_stew.add_ingredient(onion, 207)

Beef_stew.add_ingredient(mushroom, 330)
Beef_stew.add_ingredient(carrot, 306)

Beef_stew.add_ingredient(salt, 13)

Now, when I run the script I have to pay close attention to the single serving size of my
meal. I have the script set up in such a way that I can see what the total serving size (in
grams) is when I enter a 1 into the serving size:

# Calculate nutrition per single serving for Beef Stew

single_serving_size_Beef_stew = 1

nutrition_single_serving_Beef_stew = {}

for key, value in nutrition_info_Beef_stew.items():

nutrition_single_serving_Beef_stew[key] = value / single_serving_size_Beef_stew

And now below I have the total nutrition facts for my beef stew, FYI you have to be careful
when adding water or broth to a recipe such as this and include that weight, for this
particular example I cooked it in a pressure cooker with no added liquid so I can safely
assume that this is relatively accurate, although not perfect, it works for my general sense
of accuracy, other recipes can have a greater accuracy for example those without
evaporating liquid. But you can always increase accuracy since you already have the
weights of your ingredients and liquid, you can always weigh the whole meal after cooking
and subtract your post cooked weight from your precooked weight and make that
subtraction to your liquid for true accuracy you should keep in mind that when broth
evaporates you are only losing water and not necessarily the broth since the broth simply
concentrates and does not necessarily lose its nutritional value, so when using broth you
must have a section for water(even if you didn’t use any) for when you go to subtract the
evaporated liquid from the total weight of the recipe:

Nutrition per Single Serving for Beef Stew (total serving size/1):

Total Serving Size: 2201.0


Total Calories: 3052.798487239484

Total Fiber: 21.369142769041012

Total Carbs: 66.8974932433658

Total Fat: 177.25882352941179

Total Protein: 299.4913934084272

Total Sugar: 29.197938002212915

Total Sodium: 6346.294117647059

And now I look at the carbs, fat, and protein of this meal and I say, okay what is my “limiting
agent” I want, e.g. how much protein do I want to consume per meal, with each serving of
this stew I want to consume 30 grams of protein, so I would divide the total protein by the
amount of protein I want in a serving (299.49/30)~ 10 servings. Therefore, I would enter a 10
in the place where there was once a 1:

# Calculate nutrition per single serving for Beef Stew

single_serving_size_Beef_stew = 10

nutrition_single_serving_Beef_stew = {}

for key, value in nutrition_info_Beef_stew.items():

nutrition_single_serving_Beef_stew[key] = value / single_serving_size_Beef_stew

I run the script again and I receive the nutrition facts for one serving of beef stew when it is
divided into 10 servings:

Nutrition per Single Serving for Beef Stew (total serving size/10):

Total Serving Size: 220.1

Total Calories: 305.2798487239484


Total Fiber: 2.1369142769041014

Total Carbs: 6.68974932433658

Total Fat: 17.725882352941177

Total Protein: 29.94913934084272

Total Sugar: 2.9197938002212913

Total Sodium: 634.6294117647059

Now I can see that when I go to divide the servings I will be measuring out 220 grams of this
stew, obviously not perfect since some servings will get more meat than others, but it still
gives you a good idea of how you can use this script to build a complete meal plan with
recipes as well as single ingredients.

Now at the bottom of the script you will notice some more fancy features such as:

# Calculate nutrition per single serving for any recipe

def print_nutrition_per_single_serving(recipe_name, nutrition_info, single_serving_size):

print(f"\nNutrition per Single Serving for {recipe_name} (total serving


size/{single_serving_size}):")

nutrition_per_single_serving = {}

for key, value in nutrition_info.items():

nutrition_per_single_serving[key] = value / single_serving_size

for key, value in nutrition_per_single_serving.items():

print(f"{key}: {value}")

You never have to do anything with this, it is just calling a function that allows me to print
single serving sizes of any recipe. Below that is a section that allows me to show what I
want to be printed:

#######################

# Example usage: Calculate nutrition per single serving for any recipe
print_nutrition_per_single_serving("Ceasar Dressing", nutrition_info_Ceasar_Dressing,
single_serving_size_Ceasar_Dressing)

print_nutrition_per_single_serving("Beef Stew", nutrition_info_Beef_stew,


single_serving_size_Beef_stew)

print_nutrition_per_single_serving("beef stroganof", nutrition_info_beef_stroganof,


single_serving_size_beef_stroganof)

print_nutrition_per_single_serving("nut pouch", nutrition_info_nut_pouch,


single_serving_size_nut_pouch)

print_nutrition_per_single_serving("bacon egg salad", nutrition_info_bacon_egg_salad,


single_serving_size_bacon_egg_salad)

print_nutrition_per_single_serving("sweet potato mash",


nutrition_info_sweet_potatoe_mash, single_serving_size_sweet_potatoe_mash)

print_nutrition_per_single_serving("pan chicken", nutrition_info_pan_chicken,


single_serving_size_pan_chicken)

print_nutrition_per_single_serving("salmon", nutrition_info_salmon,
single_serving_size_salmon)

print_nutrition_per_single_serving("guacamole", nutrition_info_guacamole,
single_serving_size_guacamole)

print_nutrition_per_single_serving("platanos", nutrition_info_platanos,
single_serving_size_platanos)

#############################

As of right now this will print all of these recipes and show me what the nutrition facts are
for one of my already decided single serving sizes. Now, for example, if I only want to see
the nutrition facts for ceasar dressing, beef stew, and beef stroganoff, I would put a “#”
symbol in front of everything else:

#######################

# Example usage: Calculate nutrition per single serving for any recipe

print_nutrition_per_single_serving("Ceasar Dressing", nutrition_info_Ceasar_Dressing,


single_serving_size_Ceasar_Dressing)
print_nutrition_per_single_serving("Beef Stew", nutrition_info_Beef_stew,
single_serving_size_Beef_stew)

print_nutrition_per_single_serving("beef stroganof", nutrition_info_beef_stroganof,


single_serving_size_beef_stroganof)

#print_nutrition_per_single_serving("nut pouch", nutrition_info_nut_pouch,


single_serving_size_nut_pouch)

#print_nutrition_per_single_serving("bacon egg salad", nutrition_info_bacon_egg_salad,


single_serving_size_bacon_egg_salad)

#print_nutrition_per_single_serving("sweet potato mash",


nutrition_info_sweet_potatoe_mash, single_serving_size_sweet_potatoe_mash)

#print_nutrition_per_single_serving("pan chicken", nutrition_info_pan_chicken,


single_serving_size_pan_chicken)

#print_nutrition_per_single_serving("salmon", nutrition_info_salmon,
single_serving_size_salmon)

#print_nutrition_per_single_serving("guacamole", nutrition_info_guacamole,
single_serving_size_guacamole)

#print_nutrition_per_single_serving("platanos", nutrition_info_platanos,
single_serving_size_platanos)

#############################

Now when I print I will only see the nutrition facts for those three recipes.

Now, if I want to see what the daily nutrition facts would be for the day, if I were to eat a
single serving of platanos, beef stew, and bacon egg salad I would have this:

# Add the nutrition facts for any recipes together

total_nutrition_day = {}

for key in nutrition_single_serving_Beef_stew.keys():


total_nutrition_day[key] = nutrition_single_serving_platanos[key] +
nutrition_single_serving_Beef_stew[key] + nutrition_single_serving_bacon_egg_salad[key]

and this output would be:

Total Nutrition for the Day (One Serving of Each Recipe):

Total Serving Size: 409.2711247180148

Total Calories: 824.2647688473314

Total Fiber: 2.795966001042032

Total Carbs: 15.676818289853822

Total Fat: 60.58961376493878

Total Protein: 54.61339386411514

Total Sugar: 6.993931731255774

Total Sodium: 1316.1608007431141

Adding or subtracting meals for your day would be as easy as copy pasting +
nutrition_single_serving_nut_pouch[key] if we wanted to add a serving of nut pouch for the
day and the resulting script and ouput would be as follows:

# Add the nutrition facts for any recipes together

total_nutrition_day = {}

for key in nutrition_single_serving_Beef_stew.keys():

total_nutrition_day[key] = nutrition_single_serving_platanos[key] +
nutrition_single_serving_Beef_stew[key] + nutrition_single_serving_bacon_egg_salad[key]
+ nutrition_single_serving_nut_pouch[key]

Total Nutrition for the Day (One Serving of Each Recipe):

Total Serving Size: 479.2711247180148


Total Calories: 1254.2647688473314

Total Fiber: 8.795966001042032

Total Carbs: 31.17681828985382

Total Fat: 99.08961376493878

Total Protein: 66.61339386411514

Total Sugar: 15.493931731255774

Total Sodium: 1348.6608007431141

I have already done quite a bit of work for you in entering some ingredients and recipes but
it is up to you to customize this to fit the ingredients you cook with as well as enter the
recipes that you eat. It’s a simple but powerful script in calorie counting. Good luck!
class CustomIngredient:

def __init__(self, name, serving_size, calories, fiber, carbs, fat, protein, sugar, sodium):

self.name = name

self.serving_size = serving_size

self.calories = calories

self.fiber = fiber

self.carbs = carbs

self.fat = fat

self.protein = protein

self.sugar = sugar

self.sodium = sodium

class Recipe:

def __init__(self):

self.ingredients = []

def add_ingredient(self, ingredient, amount):

self.ingredients.append((ingredient, amount))

def get_nutrition(self):

total_serving_size = 0

total_calories = 0

total_fiber = 0

total_carbs = 0

total_fat = 0

total_protein = 0
total_sugar = 0

total_sodium = 0

for ingredient, amount in self.ingredients:

total_serving_size += amount

total_calories += (ingredient.calories / ingredient.serving_size) * amount

total_fiber += (ingredient.fiber / ingredient.serving_size) * amount

total_carbs += (ingredient.carbs / ingredient.serving_size) * amount

total_fat += (ingredient.fat / ingredient.serving_size) * amount

total_protein += (ingredient.protein / ingredient.serving_size) * amount

total_sugar += (ingredient.sugar / ingredient.serving_size) * amount

total_sodium += (ingredient.sodium / ingredient.serving_size) * amount

return {

'Total Serving Size': total_serving_size,

'Total Calories': total_calories,

'Total Fiber': total_fiber,

'Total Carbs': total_carbs,

'Total Fat': total_fat,

'Total Protein': total_protein,

'Total Sugar': total_sugar,

'Total Sodium': total_sodium}

# Define ingredients

# name, serving_size, calories, fiber, carbs, fat, protein, sugar, sodium

bok_choy = CustomIngredient("bok choy", 170, 20, 1.7, 3, 0, 2.7, 1.4, 0)


onion = CustomIngredient("onion", 94, 41, 1.3, 9.5, 0, 1.3, 4.4, 0)

mushroom = CustomIngredient("mushroom", 180, 51, 4, 9.5, 0, 4, 4, 0)

carrot = CustomIngredient("carrot", 46, 16, 1.4, 3.8, 0, 0, 1.6, 0)

salt = CustomIngredient("Salt", 1, 0, 0, 0, 0, 0, 0, 420)

sweet_potatoes = CustomIngredient("sweet potatoes", 114, 103, 3.8, 24, 0, 2.3, 7.4, 0)

coconut_milk = CustomIngredient("coconut milk", 44, 120, 0, 1, 12, 0, 1, 30) #44


grams=1serving(1/3 cup) density of coconut milk (.55g/ml) and 80ml = 1 serving

beef_bouillon = CustomIngredient("beef bouillon", 6, 15, 0, 2, .5, 0, 0, 350)

olive_oil = CustomIngredient("olive oil", 14, 119, 0, 0, 14, 0, 0, 0)

chuck_roast = CustomIngredient("chuck roast", 85, 201, 0, 0, 13, 21, 0, 65)

chicken_breast = CustomIngredient("chicken breast", 189, 227, 0, 0, 5, 43, 0, 85)

eggs = CustomIngredient("eggs", 50, 72, 0, 0, 4.8, 6.3, 0, 71)

bacon = CustomIngredient("bacon", 35, 161, 0, 0, 12, 12, 0, 581)

cashews = CustomIngredient("cashews", 28, 160, 0, 9, 12, 5, 12, 0)

pecans = CustomIngredient("pecans", 28, 200, 3, 4, 20, 3, 1, 0)

walnuts= CustomIngredient("walnuts", 28, 180, 2, 4, 18, 4, 1, 0)

almonds= CustomIngredient("almonds", 28, 160, 4, 6, 14, 6, 1, 0)

pistachios= CustomIngredient("pistachios", 28, 160, 3, 8, 13, 6, 2, 65)

Salmon = CustomIngredient("salmon", 114, 234, 0, 0, 14, 25, 0, 69)

coconut_aminos = CustomIngredient("coconut aminos", 18.6, 11.7, 0, 3, 0, 0, 3, 267)

red_wine_vinegar = CustomIngredient("red wine vinegar", 15, 2.5, 0, 0, 0, 0, 0, 0)

coconut_oil = CustomIngredient("coconut oil", 14, 130, 0, 0, 15, 0, 0, 0)

stew_meat = CustomIngredient("stew meat", 85, 162, 0, 0, 5.8, 28, 0, 57)

arrowroot = CustomIngredient("arrowroot", 9, 35, 0, 8, 0, 0, 0, 0)

avocado = CustomIngredient("avocado", 201, 322, 13, 17, 29, 4, 1.3, 14)

tomato = CustomIngredient("tomato", 123, 22, 1.5, 4.8, 0, 1, 3.2, 6.2)


jalapeno = CustomIngredient("jalapeno", 14, 4.1, 0.4, 1, 0, 0, .6, 0)

plantains = CustomIngredient("plantains", 240, 278, 5.5, 75, .4, 1.9, 34, 12)

water = CustomIngredient("water", 237, 0, 0, 0, 0, 0, 0, 0) #1 cup

dijon = CustomIngredient("dijon", 5, 5, 0, 0, 0, 0, 0, 60)

avocado_oil = CustomIngredient("avocado oil", 14, 120, 0, 0, 14, 0, 0, 0)

sherry_wine_vinegar = CustomIngredient("sherry wine vinegar", 15, 5, 0, 2, 0, 0, 2, 0)

egg_yolk = CustomIngredient("egg yolk", 17, 55, 0, .6, 4.5, 2.7, .1, 8.2)

garlic = CustomIngredient("garlic", 3, 4.5, .1, 1, 0, .2, 0, .5)

anchovie = CustomIngredient("anchovie", 16, 35, 0, 0, 1.5, 5, 0, 960)

tobasco = CustomIngredient("tobasco", 5, 0, 0, 0, 0, 0, 0, 35)

worchestershire = CustomIngredient("worchestershire", 5, 5, 0, 1, 0, 0, 1, 65)

lemon_juice = CustomIngredient("lemon juice", 122, 27, 0.4, 8.5, .3, .4, 3.1, 1.2)

#Define Recipes

Ceasar_Dressing = Recipe()

Ceasar_Dressing.add_ingredient(dijon, 66)

Ceasar_Dressing.add_ingredient(avocado_oil, 457)

Ceasar_Dressing.add_ingredient(sherry_wine_vinegar, 70)

Ceasar_Dressing.add_ingredient(egg_yolk, 108)

Ceasar_Dressing.add_ingredient(garlic, 29)

Ceasar_Dressing.add_ingredient(anchovie, 51)

Ceasar_Dressing.add_ingredient(tobasco, 5)

Ceasar_Dressing.add_ingredient(worchestershire, 72)

Ceasar_Dressing.add_ingredient(lemon_juice, 159)
Beef_stew = Recipe()

Beef_stew.add_ingredient(chuck_roast, 1159)

Beef_stew.add_ingredient(bok_choy, 186)

Beef_stew.add_ingredient(onion, 207)

Beef_stew.add_ingredient(mushroom, 330)

Beef_stew.add_ingredient(carrot, 306)

Beef_stew.add_ingredient(salt, 13)

beef_stroganof = Recipe()

beef_stroganof.add_ingredient(onion, 92)

beef_stroganof.add_ingredient(coconut_aminos, 74.4)

beef_stroganof.add_ingredient(red_wine_vinegar, 60)

beef_stroganof.add_ingredient(stew_meat, 681)

beef_stroganof.add_ingredient(mushroom, 100)

beef_stroganof.add_ingredient(carrot, 100)

beef_stroganof.add_ingredient(coconut_milk, 66)

beef_stroganof.add_ingredient(arrowroot, 27)

beef_stroganof.add_ingredient(water, 296)

pan_chicken = Recipe()

pan_chicken.add_ingredient(olive_oil, 64)

pan_chicken.add_ingredient(bacon, 340)

pan_chicken.add_ingredient(chicken_breast, 1192)

bacon_egg_salad = Recipe()

bacon_egg_salad.add_ingredient(olive_oil, 160)
bacon_egg_salad.add_ingredient(bacon, 340)

bacon_egg_salad.add_ingredient(eggs, 1150)

salmon = Recipe()

salmon.add_ingredient(Salmon, 114)

guacamole = Recipe()

guacamole.add_ingredient(onion, 92)

guacamole.add_ingredient(avocado, 593)

guacamole.add_ingredient(tomato, 378)

guacamole.add_ingredient(jalapeno, 120)

platanos = Recipe()

platanos.add_ingredient(plantains, 834)

platanos.add_ingredient(coconut_oil, 180)

nut_pouch = Recipe()

nut_pouch.add_ingredient(cashews, 28)

nut_pouch.add_ingredient(pecans, 28)

nut_pouch.add_ingredient(walnuts, 28)

nut_pouch.add_ingredient(almonds, 28)

nut_pouch.add_ingredient(pistachios, 28)

sweet_potatoe_mash = Recipe()

sweet_potatoe_mash.add_ingredient(sweet_potatoes, 2270)

sweet_potatoe_mash.add_ingredient(coconut_milk, 165)
sweet_potatoe_mash.add_ingredient(salt, 10)

# Get nutrition facts for Ceasar Dressing

nutrition_info_Ceasar_Dressing = Ceasar_Dressing.get_nutrition()

#print("\nNutrition Facts for Ceasar Dressing:")

for key, value in nutrition_info_Ceasar_Dressing.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for Ceasar Dressing

single_serving_size_Ceasar_Dressing = 20

nutrition_single_serving_Ceasar_Dressing = {}

for key, value in nutrition_info_Ceasar_Dressing.items():

nutrition_single_serving_Ceasar_Dressing[key] = value /
single_serving_size_Ceasar_Dressing

# Get nutrition facts for Beef Stew

nutrition_info_Beef_stew = Beef_stew.get_nutrition()

#print("\nNutrition Facts for Beef Stew:")

for key, value in nutrition_info_Beef_stew.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for Beef Stew

single_serving_size_Beef_stew = 10

nutrition_single_serving_Beef_stew = {}

for key, value in nutrition_info_Beef_stew.items():

nutrition_single_serving_Beef_stew[key] = value / single_serving_size_Beef_stew


# Get nutrition facts for beef stroganof

nutrition_info_beef_stroganof = beef_stroganof.get_nutrition()

#print("\nNutrition Facts for beef stroganof:")

for key, value in nutrition_info_beef_stroganof.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for beef stroganof

single_serving_size_beef_stroganof = 8

nutrition_single_serving_beef_stroganof = {}

for key, value in nutrition_info_beef_stroganof.items():

nutrition_single_serving_beef_stroganof[key] = value /
single_serving_size_beef_stroganof

# Get nutrition facts for Salmon

nutrition_info_salmon = salmon.get_nutrition()

#print("\nNutrition Facts for Salmon:")

for key, value in nutrition_info_salmon.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for Salmon

single_serving_size_salmon = 1

nutrition_single_serving_salmon = {}

for key, value in nutrition_info_salmon.items():

nutrition_single_serving_salmon[key] = value / single_serving_size_salmon


# Get nutrition facts for guacamole

nutrition_info_guacamole = guacamole.get_nutrition()

#print("\nNutrition Facts for guacamole:")

for key, value in nutrition_info_guacamole.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for guacamole

single_serving_size_guacamole = 4

nutrition_single_serving_guacamole = {}

for key, value in nutrition_info_guacamole.items():

nutrition_single_serving_guacamole[key] = value / single_serving_size_guacamole

# Get nutrition facts for platanos

nutrition_info_platanos = platanos.get_nutrition()

#print("\nNutrition Facts for platanos:")

for key, value in nutrition_info_platanos.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for platanos

single_serving_size_platanos = 29

nutrition_single_serving_platanos = {}

for key, value in nutrition_info_platanos.items():

nutrition_single_serving_platanos[key] = value / single_serving_size_platanos

# Get nutrition facts for Pan Chicken

nutrition_info_pan_chicken = pan_chicken.get_nutrition()
#print("\nNutrition Facts for Pan Chicken:")

for key, value in nutrition_info_pan_chicken.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for Pan Chicken

single_serving_size_pan_chicken = 12

nutrition_single_serving_pan_chicken = {}

for key, value in nutrition_info_pan_chicken.items():

nutrition_single_serving_pan_chicken[key] = value / single_serving_size_pan_chicken

# Get nutrition facts for Bacon egg salad

nutrition_info_bacon_egg_salad = bacon_egg_salad.get_nutrition()

#print("\nNutrition Facts for Beef Stew:")

for key, value in nutrition_info_bacon_egg_salad.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for bacon egg salad

single_serving_size_bacon_egg_salad = 10.7

nutrition_single_serving_bacon_egg_salad = {}

for key, value in nutrition_info_bacon_egg_salad.items():

nutrition_single_serving_bacon_egg_salad[key] = value /
single_serving_size_bacon_egg_salad

# Get nutrition facts for sweet potato mash

nutrition_info_sweet_potatoe_mash = sweet_potatoe_mash.get_nutrition()

#print("\nNutrition Facts for sweet potato mash:")


for key, value in nutrition_info_sweet_potatoe_mash.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for sweet potato mash

single_serving_size_sweet_potatoe_mash = 25

nutrition_single_serving_sweet_potatoe_mash = {}

for key, value in nutrition_info_sweet_potatoe_mash.items():

nutrition_single_serving_sweet_potatoe_mash[key] = value /
single_serving_size_sweet_potatoe_mash

# Get nutrition facts for Nut Pouch

nutrition_info_nut_pouch = nut_pouch.get_nutrition()

#print("\nNutrition Facts for Nut Pouch:")

for key, value in nutrition_info_nut_pouch.items():

#print(f"{key}: {value}")

# Calculate nutrition per single serving for Nut Pouch

single_serving_size_nut_pouch = 2

nutrition_single_serving_nut_pouch = {}

for key, value in nutrition_info_nut_pouch.items():

nutrition_single_serving_nut_pouch[key] = value / single_serving_size_nut_pouch

# Calculate nutrition per single serving for any recipe

def print_nutrition_per_single_serving(recipe_name, nutrition_info, single_serving_size):

print(f"\nNutrition per Single Serving for {recipe_name} (total serving


size/{single_serving_size}):")

nutrition_per_single_serving = {}
for key, value in nutrition_info.items():

nutrition_per_single_serving[key] = value / single_serving_size

for key, value in nutrition_per_single_serving.items():

print(f"{key}: {value}")

#######################

# Example usage: Calculate nutrition per single serving for any recipe

print_nutrition_per_single_serving("Ceasar Dressing", nutrition_info_Ceasar_Dressing,


single_serving_size_Ceasar_Dressing)

print_nutrition_per_single_serving("Beef Stew", nutrition_info_Beef_stew,


single_serving_size_Beef_stew)

print_nutrition_per_single_serving("beef stroganof", nutrition_info_beef_stroganof,


single_serving_size_beef_stroganof)

print_nutrition_per_single_serving("nut pouch", nutrition_info_nut_pouch,


single_serving_size_nut_pouch)

#print_nutrition_per_single_serving("bacon egg salad", nutrition_info_bacon_egg_salad,


single_serving_size_bacon_egg_salad)

#print_nutrition_per_single_serving("sweet potato mash",


nutrition_info_sweet_potatoe_mash, single_serving_size_sweet_potatoe_mash)

#print_nutrition_per_single_serving("pan chicken", nutrition_info_pan_chicken,


single_serving_size_pan_chicken)

#print_nutrition_per_single_serving("salmon", nutrition_info_salmon,
single_serving_size_salmon)

#print_nutrition_per_single_serving("guacamole", nutrition_info_guacamole,
single_serving_size_guacamole)

#print_nutrition_per_single_serving("platanos", nutrition_info_platanos,
single_serving_size_platanos)

#############################
# Add the nutrition facts for any recipes together

total_nutrition_day = {}

for key in nutrition_single_serving_Beef_stew.keys():

total_nutrition_day[key] = nutrition_single_serving_platanos[key] +
nutrition_single_serving_Beef_stew[key] + nutrition_single_serving_bacon_egg_salad[key]
+ nutrition_single_serving_nut_pouch[key]

# Print the total nutrition for the day

print("\nTotal Nutrition for the Day (One Serving of Each Recipe):")

for key, value in total_nutrition_day.items():

print(f"{key}: {value}")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy