Question: Instructions: Submit your code along with explanations and test results that demonstrate the implementation of the required features. Submit a single . pdf document in
Instructions:
Submit your code along with explanations and test results that demonstrate the implementation of the required features.
Submit a single pdf document in Canvas with both code and results.
Always remember, "Practice makes perfect!"
Exercise : points Meal and Nutrition Tracker
Objective: Develop code that allows users to log daily food intake, track nutritional values, and monitor their diet against personal health goals, supporting informed food choices and dietary objectives.
Classes and Components:
Fooditem
Variables: name private calories private proteins private carbs private fats private Instance Methods:
self name, calories, proteins, carbs, fade: Constructor to initialize a new food item with nutritional info.
Getter Methods for each private variable and a display method to print the food item.
DailyLog
Variables: date private fooditems a list of Fooditem instances, private Instance Methods:
self date: Constructor to initialize a new daily log addfooditem: Adds a Fooditem instance to the log
gettotalcalories: Calculates total calories consumed on that day.
gettotalnutrients: Calculates total proteins, carbs, and fats consumed.
display: Print the daily log
NutritionProfile
Variables: userid private dailylogs a dictionary with dates as keys and DailyLog instances as values Instance Methods:
self userid: Constructor to initialize a new nutrition profile.
adddailylogself dailylog: Adds a DailyLog instance to the profile.
getlogbydateself date: Retrieves a DailyLog by date.
display: Print the nutrition profile.
Testing:
Example:
# Create some food items
apple FoodItemApple
banana FoodItemBanana
# Create a daily and add food items
dailylog DailyLog
dailylogaddfooditemapple
dailylogaddfooditembananaExercise : points Create a moduleObjective: Save the classes Fooditem, DailyLog, and NutritionProfile into a Python file named nutritiontracker.py This file will act as your module and import it to another jupyter notebook to produce the same output as in Exercise
Exercise : points BONUS Plot the daily log
Explore the package matplotlib and create a bar plot from the daily log Implement the plot as another method, example: dailylogplotnutrients Example:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
