Caloric Balance Solution

$30.00 $24.90

Description

How many calories should you eat each day? It’s a commonly-asked question, and the answer is that it’s different for each person depending on their physical characteristics, activity, and whether they want to lose weight, gain weight, or maintain their current weight.

Calories are units of energy that our bodies consume and expend each day. If we consume the same number of calories that we expend, then our body weight does not change. If we consume fewer calories than we expend (a caloric deficit), then our body weight decreases, and if we consume more calories than we expend (a caloric surplus), then our body weight increases. We consume calories by eating food, and we expend calories by moving around and exercising (and even while resting or sleeping).

By leveraging a little bit of math, we can write a program that helps us to determine the number of calories that we should consume in order to lose weight, gain weight, or maintain our current weight, depending on our goals.

Calculations

You can calculate a person’s daily caloric balance to determine if the person ends the day with a caloric deficit, a caloric surplus, or a stable balance. The calculation is simple: calories consumed minus calories expended. But how are each of these calculated?

The number of calories a person consumes in a day is calculated by adding the number of calories of each food item that the person eats during the day. It’s that simple.

The number of calories a person expends in a day is calculated by adding two values: 1) the number of calories that the person’s body expends while at rest (called the Basal Metabolic Rate , or BMR), and 2) the number of calories that the person expends while moving around or exercising during the day (which depends on the level of physical activity or how rigorous the exercise is).

There are simple formulas to calculate both the BMR and the number of calories expended through physical activity:

BMR: there are two formulas to calculate this: one for men and one for women. In either case, the person’s weight, height, and age are needed. Here are the formulas:

Men: BMR = 66 + (12.7 * height in inches) + (6.23 * weight in pounds) – (6.8 * age in years)

Women: BMR = 655 + (4.7 * height in inches) + (4.35 * weight in pounds) – (4.7 * age in years)

Physical activity: each type of physical activity expends a different number of calories. Refer to this table for a list of physical activities and the number of calories that each activity expends per minute, per pound. So, in order to calculate the total number of calories expended for an activity, you’ll need to know the person’s weight and the duration of the activity in minutes.

Assignment

Your assignment is to create a Python program that uses a class to calculate and track a person’s caloric balance throughout a day.

Your program should start by asking the user for a person’s physical characteristics that are needed for the calculations. This includes the person’s gender, weight, height, and age. Your program should use this information to calculate the person’s BMR, subtract it from the caloric balance, and then print the updated caloric balance. The caloric balance should start at 0, so after subtracting the BMR, the caloric balance will be a negative number. Then, your program should display a menu that provides the user with three options:

Record Food Consumption: this option will ask the user for the number of calories of the food item that was consumed. Your program should add this number to the caloric balance and then print the updated caloric balance.

Record Physical Activity: this option will ask the user to select an activity from a list of choices (you must include at least five different activities for the user to choose from), as well as the number of minutes that the activity was performed. Your program should use this information to calculate the number of calories expended, subtract this number from the caloric balance, and then print the updated caloric balance.

Quit: this option should terminate your program.

Extra Challenges

In addition to printing the person’s caloric balance each time, also offer suggestions for losing weight, gaining weight, or maintaining current weight, based on the current caloric balance. To maintain their current weight, a person should have a caloric balance of 0. To lose weight, a person should have a caloric deficit of about 500 calories per day (a caloric balance of -500 calories), and, to gain weight, a person should have a caloric surplus of about 500 calories per day (a caloric balance of +500 calories).

When the user records physical activity, let them know how many calories they just burned to make them feel good about themselves.

Hints

Strongly consider the following suggestions while creating the Python class for your program:

Think of an appropriate name for your class. The class will be responsible for calculating a person’s caloric balance.

Consider adding a member variable that stores the current caloric balance. This value should start at 0, before calculations are made.

Consider adding a method to calculate the person’s BMR and subtract it from the caloric balance. Think about what parameters are necessary to calculate the BMR.

Consider adding a method to get the current caloric balance. This will be useful in order to print the caloric balance.

Consider adding a method to set the person’s weight into a member variable. This will be useful information to have when you need to calculate calories expended by physical activity.

Consider adding a method to record calories consumed from food. These calories should be added to the caloric balance.

Consider adding one method for each physical activity, to calculate the number of calories expended by the activity. These calories should be subtracted from the caloric balance.

Sample

Program execution:

Hi! This program will calculate your caloric balance for the day!

Before we can start, I need some information about you. Be honest! 🙂

What is your gender (f or m)? f

What is your age? 23

What is your height in inches? 65

What is your weight in pounds? 130

Thanks! Now, throughout the day, tell me each time you eat or move.

Your caloric balance is starting at -1417.9 (you need to eat something)

What would you like to do?

[f] Record Food Consumption

[a] Record Physical Activity

[q] Quit

Enter an option: f

Okay! How many calories did you just eat? 600

Sweet! Your caloric balance is now -817.9

What would you like to do?

[f] Record Food Consumption

[a] Record Physical Activity

[q] Quit

Enter an option: a

Choose an activity to record:

[j] Jump rope

[r] Running

[s] Sitting

[v] Volleyball

[w] Walking

Enter an option: j

For how many minutes did you perform this activity? 30

Awesome! Your caloric balance is now -1106.5

What would you like to do?

[f] Record Food Consumption

[a] Record Physical Activity

[q] Quit

Enter an option: f

Okay! How many calories did you just eat? 400

Sweet! Your caloric balance is now -706.5

What would you like to do?

[f] Record Food Consumption

[a] Record Physical Activity

[q] Quit

Enter an option: a

Choose an activity to record:

[j] Jump rope

[r] Running

[s] Sitting

[v] Volleyball

[w] Walking

Enter an option: v

For how many minutes did you perform this activity? 45

Awesome! Your caloric balance is now -841.05

What would you like to do?

[f] Record Food Consumption

[a] Record Physical Activity

[q] Quit

Enter an option: f

Okay! How many calories did you just eat? 900

Sweet! Your caloric balance is now 58.95

What would you like to do?

[f] Record Food Consumption

[a] Record Physical Activity

[q] Quit

Enter an option: q

Leaving? You should do this again tomorrow. Stay healthy!