//Comment

Nutrition Tracker

Featured image

In the United States, 42.4 percent of adults suffer from obesity. Some of these people may also have pre-existing conditions, but the majority simply have a sedentary lifestyle and unhealthy diets. Although these people care about their health, the prevalence of unhealthy foods in today’s world leads to malnutrition in many people. To combat this, our group, //comment, created a program that lets the user know how many carbohydrates and how much of various important nutrients they should consume in a day.

Before the main program runs, the Food class, the type used for all foods the user inputs, is instantiated in the file food.py. Beneath the food class, a list of various common foods, such as apples, cucumbers, and pears, is created. Then, foods.py is passed to the main function. First, in the main function, the program asks for the user’s age, gender, and activity level, while also checking for errors in each one. Next, it uses those values to determine the recommended amounts of calories, protein(g), carbohydrates(g), sodium(mg), calcium(mg), and iron(mg). Then, the date is printed, and the program enters a while loop.

In the loop, the program first tells the user how many of each nutrient they still need to consume, and if they have eaten too much, it warns them to limit their intake of that nutrient. Then, it gives them the option to either enter a food they have eaten, or end the loop. If the user chooses to enter a new food, it asks them for the name of the food. If the food they enter is one of the foods in the list of common foods from foods.py, the program simply asks the user how much of the food they ate. However, if the food is not in the list, the user is asked to refer to the nutritional label to enter the amount of each nutrient in the food. After the amounts of the nutrients are received, either from the list or through user input, the program subtracts the amount of each nutrient consumed from the amount of each nutrient the user still needs to consume and returns to the top of the loop.

Code File
Project Video

Creators: Kouki, Manas, Aneesh